This page is a snapshot from the LWG issues list, see theLibrary Active Issues List for more information and the meaning ofC++11 status.
std::thread::id should be trivially copyableSection: 32.4.3.2[thread.thread.id]Status:C++11Submitter: Anthony WilliamsOpened: 2009-11-24Last modified: 2016-01-28
Priority:Not Prioritized
View all otherissues in [thread.thread.id].
View all issues withC++11 status.
Discussion:
The class definition ofstd::thread::id inN3000is:
class thread::id {public: id();};Typically, I expect that the internal data members will either bepointers or integers, so that in practice the class will be triviallycopyable. However, I don't think the current wording guarantees it, andI think it would be useful. In particular, I can see a use forstd::atomic<std::thread::id> to allow athreadto claim ownership of a data structure atomicly, andstd::atomic<T> requires thatT is triviallycopyable.
[2010-02-12 Moved to Tentatively Ready after 7 positive votes on c++std-lib.]
Proposed resolution:
Add a new sentence to 32.4.3.2[thread.thread.id] p1:
1 An object of type
thread::idprovides a unique identifier foreach thread of execution and a single distinct value for allthreadobjects that do not represent a thread of execution(32.4.3[thread.thread.class]). Each thread of execution has anassociatedthread::idobject that is not equal to thethread::idobject of any other thread of execution and that isnot equal to thethread::idobject of anystd::threadobject that does not represent threads of execution. The library mayreuse the value of athread::idof a terminated thread that canno longer be joined.thread::idshall be a triviallycopyable class (11[class]).