Mark
Mark

Reputation: 2112

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

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

Upvotes: 12

Views: 1935

Answers (1)

Andy Prowl
Andy Prowl

Reputation: 126462

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 ]

Upvotes: 18

Related Questions