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.

相关文章

本程序的编译和运行环境如下(如果有运行方面的问题欢迎在评...
水了一学期的院选修,万万没想到期末考试还有比较硬核的编程...
补充一下,先前文章末尾给出的下载链接的完整代码含有部分C&...
思路如标题所说采用模N取余法,难点是这个除法过程如何实现。...
本篇博客有更新!!!更新后效果图如下: 文章末尾的完整代码...
刚开始学习模块化程序设计时,估计大家都被形参和实参搞迷糊...