There shall be named types corresponding to the integral specializations of
atomic
,as specified in Table 145,and a named typeatomic_bool
corresponding to the specifiedatomic<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是专业化的,而不是基础类.
解决方法
在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.