c++のスレッドで返り値が欲しいのならば
返り値に代わる変数を渡せばいいじゃない。
#include <thread> #include <stdio.h> int th(int* ret) { printf("1"); ret = 1; return 1; } int main() { int ret; std::thread th(th, &ret); th.join(); return 0; }
ね、簡単でしょ。
返り値に代わる変数を渡せばいいじゃない。
#include <thread> #include <stdio.h> int th(int* ret) { printf("1"); ret = 1; return 1; } int main() { int ret; std::thread th(th, &ret); th.join(); return 0; }
ね、簡単でしょ。