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++指针和引用的选择最近在看...
关于vtordisp知多少?我相信不少人看到这篇文章,多半是来自...
那些陌生的C++关键字学过程序语言的人相信对关键字并...
命令行下的树形打印最近在处理代码分析问题时,需要将代码的...
虚函数与虚继承寻踪封装、继承、多态是面向对象语言的三大特...