Content deleted Content added
Added a reference, sorted out reference links. |
Fix typo in name of "is_pod" macro. |
||
Line 5:
Plain old data structures are appropriate when there is a part of a system where it should be clearly indicated that the detailed logic for data manipulation and integrity are elsewhere. PODSs are often found at the boundaries of a system, where information is being moved to and from other systems or persistent storage and the problem ___domain logic that is found in other parts of the system is not relevant. For example, PODS would be convenient for representing the field values of objects that are being constructed from external data, in a part of the system where the semantic checks and interpretations needed for valid objects have not yet been applied.
A PODS type in [[C++]] is defined as either a scalar type or a PODS class.<ref>{{cite book | author = Information Technology Industry Council | publisher = ISO/IEC | ___location = Geneva | title = Programming languages — C++ | id = 14882:2003(E) | edition = Second edition | date = 2003-10-15 }}</ref> A PODS class has no user-defined copy assignment operator, no user-defined destructor, and no non-static data members that are not themselves PODS. Moreover, a PODS class must be an aggregate, meaning it has no user-declared constructors, no private nor protected non-static data, no base classes and no virtual functions.<ref>[http://www.fnal.gov/docs/working-groups/fpcltf/Pkg/ISOcxx/doc/POD.html "C++ Language Note: POD Types"], by Walter E. Brown, [[Fermi National Accelerator Laboratory]], September 29, 1999; last updated November 29, 1999.</ref> The standard includes statements about how PODS must behave in C++. The <tt>type_traits</tt> library in the STL, provides a function known as <tt>
In certain contexts, C++ allows only PODS types to be used. For example, a <tt>union</tt> in C++98 cannot contain a class that has [[virtual function]]s or nontrivial constructors or destructors. This restriction is imposed because the compiler cannot determine which constructor or destructor should be called for a union. PODS types can also be used for interfacing with [[C (programming language)|C]], which supports only PODS.
|