ぶろぐめんどくさい

技術系の記事と漫画レビューが入り混じった混沌

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;
}

ね、簡単でしょ。