Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

10
  • from en.cppreference.com/w/cpp/thread/thread/thread, it clearly says it will copy/move the arguments to thread-accessible storage Commented Mar 31, 2016 at 19:22
  • 1
    So what? That doesn't mean it should compile. Make sure you have refreshed my answer to see the latest version which explains that the copies are forwarded as rvalues, so can't bind to non-const lvalue reference parameters. Commented Mar 31, 2016 at 19:24
  • Can you elaborate the std::result_of error? Is that trying to do what the standard is requiring as you said, ie pass the copies as rvalues? Commented Mar 31, 2016 at 19:24
  • The result_of error means that you cannot call a function of type void(double&) with an argument of type double, which is true, because you cannot bind a non-const lvalue reference to an rvalue. So you cannot construct a std::thread with those arguments, because calling f1 with an rvalue won't compile. Commented Mar 31, 2016 at 19:25
  • I am kinda confused. Why the argument type of double is rvalue? Commented Mar 31, 2016 at 19:27