c – 为什么std :: atomic_ {char,schar等等} typedefs被允许为一个基类std :: atomic的typedef,而不是只原子?

前端之家收集整理的这篇文章主要介绍了c – 为什么std :: atomic_ {char,schar等等} typedefs被允许为一个基类std :: atomic的typedef,而不是只原子?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
C 11 [atomics.types.generic] p7:

There shall be named types corresponding to the integral specializations of atomic,as specified in Table 145,and a named type atomic_bool corresponding to the specified atomic<bool>. Each named type is a either typedef to the corresponding specialization or a base class of the corresponding specialization. If it is a base class,it shall support the same member functions as the corresponding specialization.

(加重)

让std :: atomic_char不等同于std :: atomic< char>等所有其他类型的理由是什么?这有什么灵活性,为什么它有用?乍一看,我不明白为什么这些不需要是typedefs std :: atomic< T>直接专业化.

注意,N2427提出了< atomic>说typedef是专业化的,而不是基础类.

解决方法

它可能在那里,因为有人已经使用std :: atomic_ *类型作为基类实现了原子,并且抱怨足够/提供了一个很好的争论.

MSVC建议这样的一个实现.

this年,据说

Remove the definional base-class relationship between atomic_…. named types and the corresponding specializations of the atomic template class. The base-class relationship is now implementation-dependent. This change ensures compatibility with C. Some member functions and operators,that were formerly inherited from the base class,must be hoisted from the named types to the specializations.

原文链接:https://www.f2er.com/c/115536.html

猜你在找的C&C++相关文章