c++ - 原子类型的大小

标签 c++

标准是否表示​​ sizeof(std::atomic<T>)等于sizeof(T)

(我正在研究构建原子和其他类型的 union ,以便在理想情况下不应具有 STL 类型的 ABI 中使用。如果大小相同,则这可行)。

最佳答案

[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

不,你不能这样假设。这是尽力的努力,但不保证。

关于c++ - 原子类型的大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26164094/

相关文章:

处理 STL 容器时的 C++ 类专门化

c++ - 从 OpenCV 打印 String* 的内容

c++ - C++ 中的 Mergesort 实现错误

c++ - 继承一个 std::container 包括它的 boost 序列化

c++ - 使用 noexcept 作为 lambda 修饰符或参数约束

c++ - 双端队列中指针的自定义比较器

c++ - 是否有任何理由使用 C 而不是 C++ 进行嵌入式开发?

c++ - 在 OpenCv 3.2 中使用 ORB、Fast、Brsik 等特征描述符

c++ - 初始化一个抽象类?

c++ - 将 std::complex<double> 类型转换为 __complex128