c++ POD types
来源:互联网 发布:如何进入sm圈子知乎 编辑:程序博客网 时间:2024/05/16 10:24
A POD is a type (including classes) where the C++ compiler guarantees that there will be no "magic" going on in the structure: for example hidden pointers to vtables, offsets that get applied to the address when it is cast to other types (at least if the target's POD too), constructors, or destructors. Roughly speaking, a type is a POD when the only things in it are built-in types and combinations of them. The result is something that "acts like" a C type.
Less informally:
- int, char, wchar_t, bool, float, double are PODs, as are long/short and signed/unsigned versions of them.
- pointers (including pointer-to-function and pointer-to-member) are PODs,
- enums are PODs
- a const or volatile POD is a POD.
- a class, struct or union of PODs is a POD provided that all non-static data members are public, and it has no base class and no constructors, destructors, or virtual methods. Static members don't stop something being a POD under this rule.
- Wikipedia is wrong to say that a POD cannot have members of type pointer-to-member. Or rather, it's correct for the C++98 wording, but TC1 made explicit that pointers-to-member are POD.
Formally (C++03 Standard):
3.9(10): "Arithmetic types (3.9.1), enumeration types, pointer types, and pointer to member types (3.9.2) and cv-qualified versions of these types (3.9.3) are collectively caller scalar types. Scalar types, POD-struct types, POD-union types (clause 9), arrays of such types and cv-qualified versions of these types (3.9.3) are collectively called POD types"
9(4): "A POD-struct is an aggregate class that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-define copy operator and no user-defined destructor. Similarly a POD-union is an aggregate union that has no non-static data members of type non-POD-struct, non-POD-union (or array of such types) or reference, and has no user-define copy operator and no user-defined destructor.
8.5.1(1): "An aggregate is an array or class (clause 9) with no user-declared constructors (12.1), no private or protected non-static data members (clause 11), no base classes (clause 10) and no virtual functions (10.3)."
- 『C/C++』POD types
- What’s associated between C and C++ -- POD types
- What’s associated between C and C++ -- POD types
- POD Types Revisited
- c++ POD types
- c++POD 简介
- [C++]什么是POD?
- C 1.6 Types
- SQL & C Data Types
- POD
- POD
- POD
- pod
- POD
- pod
- User-Defined Types in C
- c++POD一句话, 及延伸到 函数
- types
- Object-Oriented JavaScript
- winpcap编程使用
- android 动态背景的实现以及SurfaceView中添加EditText控件
- 解决启动WebLogic输入用户名密码问题
- 编写操作系统
- c++ POD types
- Centos6.3开不了机
- 几种数据分页的总结 (服务器端的分页)
- 用arcgis的silverlight API连接Geoserver
- 第一天 XHTML CSS基础知识 文章出处:标准之路(http://www.aa25.cn)
- 一个first Hibernate 测试
- Mac10.7.5 XCode4.5.2 ios6编译VLC1.1.0
- 解决vs2010“创建或打开C++浏览数据库文件 发生错误”的问题"
- Java基础_异常