Reputation: 8591
Does the standard say that sizeof(std::atomic<T>)
is equal to sizeof(T)
?
(I'm investigating building union of atomic and other types for use across an ABI that ideally should not have STL types. If the sizes are identical then this could work).
Upvotes: 10
Views: 5728
Reputation: 43662
[atomics.types.generic]/p9
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
No, you can't assume that. It's a best-effort endeavor but no guarantees.
Upvotes: 14