我尝试用其他类型谓词来理解POD概念.
是否有完整的类型谓词列表,它们对应于std :: is_pod<>?
这是我目前的尝试不成立(VS2013).
struct C { // Does not assert as POD class int value; C() = default; C(int v) : value(v) { // Offends is_pod<> } }; static_assert(std::is_trivial<C>::value,""); // Assert OK static_assert(std::is_trivially_copyable<C>::value,""); // Assert OK static_assert(std::is_standard_layout<C>::value,""); // Assert OK static_assert(std::is_pod<C>::value,""); // Assert fails. Why?
解决方法
is_trivial和is_standard_layout的组合等于is_pod,对非静态成员的一些其他限制进行模数,这些限制未被< type_traits>中的一个类型特征捕获.
the draft Standard的相关报价:
[类]
10 A POD struct is a non-union class that is both a trivial class
and a standard-layout class,and has no non-static data members of type non-POD struct,non-POD union (or array of such types). Similarly,a POD union is a union that is both a trivial class and a standard-layout class,non-POD union (or array of such types). A POD class is a class that is either a POD struct or a POD union.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。