Itβs easy to understand what is going on. Just replace int with an uncopyable type (one with a private copy constructor), and the compiler will tell you exactly where libstdc++ trying to copy the argument instead of using the link. In my case, this is line 138 in the standard <tuple> header.
Whether this is the correct implementation of the standard, I canβt say at the moment.
UPDATE . The standard states that each argument to std::thread::thread must satisfy the MoveConstructible requirement and that the actual arguments passed to the thread function are constructed from a string of std::thread::thread arguments. It means that
- the stream function receives copies of the arguments, and
- Originals can be destroyed in the process.
Thus, the transfer of material by reference will not work.
source share