Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it guaranteed that sizeof(std::atomic<integer type>) == sizeof(integer type)?

Tags:

c++

c++11

atomic

In other words, is std::atomic<int> guaranteed to hold only a single int value?

like image 287
Mark Avatar asked Mar 16 '13 17:03

Mark


1 Answers

No.

Per Paragraph 29.5/9 of the C++11 Standard:

[ Note: The representation of an atomic specialization need not have the same size as its corresponding argument type. Specializations should have the same size whenever possible, as this reduces the effort required to port existing code. —end note ]

like image 62
Andy Prowl Avatar answered Oct 06 '22 00:10

Andy Prowl