std::thread::id
should be trivially copyableSection: 32.4.3.2 [thread.thread.id] Status: C++11 Submitter: Anthony Williams Opened: 2009-11-24 Last modified: 2016-01-28
Priority: Not Prioritized
View all other issues in [thread.thread.id].
View all issues with C++11 status.
Discussion:
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.
[ 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::id
provides a unique identifier for each thread of execution and a single distinct value for allthread
objects that do not represent a thread of execution (32.4.3 [thread.thread.class]). Each thread of execution has an associatedthread::id
object that is not equal to thethread::id
object of any other thread of execution and that is not equal to thethread::id
object of anystd::thread
object that does not represent threads of execution. The library may reuse the value of athread::id
of a terminated thread that can no longer be joined.thread::id
shall be a trivially copyable class (11 [class]).