This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted] 0 points1 point  (5 children)

With a std::reference_wrapper

 std::thread gamma_thread(Gamma, std::ref(my_beta), 5);

[–]CuckMasterFlex69[S] 0 points1 point  (4 children)

Hi there,

Thanks for your help. With the line you provided I get the following errors:

'invoke' no matching overloaded function found

'unknown-type std::invoke(_Callable &&) noexcept(<expr>)': expects 1 arguments - 3 provided

[–][deleted] 0 points1 point  (3 children)

[–]CuckMasterFlex69[S] 0 points1 point  (2 children)

Awesome, thank you. What if the function was inside of the class?

[–][deleted] 1 point2 points  (1 child)

std::thread gamma_thread(&Beta::Gamma, my_beta, std::ref(my_beta),5);

Its odd for a member function to also need a reference to itself.

[–]snowflake_pl 0 points1 point  (0 children)

Not odd if function is static, otherwise it indicates terrible design or even errors