Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

return value from a thread

#include <thread>
#include <future>

int simplefunc(std::string a)
{ 
    return a.size();
}

int main()
{
      auto future = std::async(simplefunc, "hello world");
      int simple = future.get();

      return simple;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #return #thread
ADD COMMENT
Topic
Name
2+3 =