Title
std::thread::id should be trivially copyable
Status
c++11
Section
[thread.thread.id]
Submitter
Anthony Williams

Created on 2009-11-24.00:00:00 last changed 154 months ago

Messages

Date: 2010-10-21.18:28:33

Proposed resolution:

Add a new sentence to [thread.thread.id] p1:

1 An object of type thread::id provides a unique identifier for each thread of execution and a single distinct value for all thread objects that do not represent a thread of execution ([thread.thread.class]). Each thread of execution has an associated thread::id object that is not equal to the thread::id object of any other thread of execution and that is not equal to the thread::id object of any std::thread object that does not represent threads of execution. The library may reuse the value of a thread::id of a terminated thread that can no longer be joined. thread::id shall be a trivially copyable class ([class]).

Date: 2010-02-12.00:00:00

[ 2010-02-12 Moved to Tentatively Ready after 7 positive votes on c++std-lib. ]

Date: 2009-11-24.00:00:00

The class definition of std::thread::id in N3000 is:

class thread::id {
public:
  id();
};

Typically, I expect that the internal data members will either be pointers or integers, so that in practice the class will be trivially copyable. However, I don't think the current wording guarantees it, and I think it would be useful. In particular, I can see a use for std::atomic<std::thread::id> to allow a thread to claim ownership of a data structure atomicly, and std::atomic<T> requires that T is trivially copyable.

History
Date User Action Args
2011-08-23 20:07:26adminsetstatus: wp -> c++11
2010-10-21 18:28:33adminsetmessages: + msg1412
2010-10-21 18:28:33adminsetmessages: + msg1411
2009-11-24 00:00:00admincreate