Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
As shown in listing 2.4, passing arguments to the callable object or function is fundamentally as simple as passing additional arguments to the std::thread constructor. But it’s important to bear in mind that by default the arguments are copied into internal storage, where they can be accessed by the newly created thread of execution, even if the corresponding parameter in the function is expecting a reference. Here’s a simple example:
void f(int i,std::string const& s); std::thread t(f,3,"hello");