[英]Size of atomic types
Does the standard say that sizeof(std::atomic<T>)
is equal to sizeof(T)
? 标准是否说
sizeof(std::atomic<T>)
等于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). (我正在调查建立原子和其他类型的联合,以便在理想情况下不应该使用STL类型的ABI中使用。如果大小相同则可以使用)。
[atomics.types.generic]/p9 [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.
这是一项尽力而为的努力但无法保证。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.