123
The C++11 standard defines std::is_standard_layout as follows:
A standard-layout class is a class that:
— has no non-static data members of type non-standard-layout class (or
array of such types) or reference,
— has no virtual functions (10.3) and no virtual base classes (10.1),
— has the same access control (Clause 11) for all non-static data members,
— has no non-standard-layout base classes,
— either has no non-static data members in the most derived class and at
most one base class with non-static data members, or has no base classes
with non-static data members, and
— has no base classes of the same type as the first non-static data member.
A standard-layout struct is a standard-layout class defined with the classkey struct or the class-key class.
A standard-layout union is a standard-layout class defined with the classkey union.
[ Note: Standard-layout classes are useful for communicating with code
written in other programming languages. Their layout is specified in 9.2.]
Having discussed object layouts, we look at another interesting problem with pointer
types and how to store them on persistent memory.
Pointers
In previous sections, we quoted parts of the C++ standard. We were describing the limits
of types which were safe to snapshot and copy and which we can binary-cast without
thinking of fixed layout. But what about pointers? How do we deal with them in our
objects as we come to grips with the persistent memory programming model? Consider
the code snippet presented in Listing 8-5 which provides an example of a class that uses
a volatile pointer as a class member.
Chapter 8 libpmemobj-Cpp: the adaptable language - C++ and persistent memory
Précédent

- 149/457

Suivant