加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c – 为什么std :: atomic_ {char,schar等等} typedefs被允许为

发布时间:2020-12-16 07:53:45 所属栏目:百科 来源:网络整理
导读: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 atomicbool . Each named type is a e
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.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读