126
We mentioned previously that a persistent memory resident class must satisfy the
following requirements:
• std::is_trivially_copyable
• std::is_standard_layout
Persistent memory developers are free to use more restrictive type traits if required.
If we want to use persistent pointers, however, we cannot rely on type traits, and we
must be aware of all problems related to copying objects with memcpy() and the layout
representation of objects. For persistent memory programming, a format description or
standardization of the aforementioned concepts and features needs to take place within
the C++ standards body group such that it can be officially designed and implemented.
Until then, developers must be aware of the restrictions and limitations to manage
undefined object-lifetime behavior.
Persistence Simplified
Consider a simple queue implementation, presented in Listing 8-6, which stores
elements in volatile DRAM.
Listing 8-6. An implementation of a volatile queue
33
#include
34
#include
35
#include
36
#include
37
Figure 8-1. Correlation between persistent memory–related C++ type traits
Chapter 8 libpmemobj-Cpp: the adaptable language - C++ and persistent memory
We mentioned previously that a persistent memory resident class must satisfy the
following requirements:
• std::is_trivially_copyable
• std::is_standard_layout
Persistent memory developers are free to use more restrictive type traits if required.
If we want to use persistent pointers, however, we cannot rely on type traits, and we
must be aware of all problems related to copying objects with memcpy() and the layout
representation of objects. For persistent memory programming, a format description or
standardization of the aforementioned concepts and features needs to take place within
the C++ standards body group such that it can be officially designed and implemented.
Until then, developers must be aware of the restrictions and limitations to manage
undefined object-lifetime behavior.
Persistence Simplified
Consider a simple queue implementation, presented in Listing 8-6, which stores
elements in volatile DRAM.
Listing 8-6. An implementation of a volatile queue
33
#include
34
#include
35
#include
36
#include
37
Figure 8-1. Correlation between persistent memory–related C++ type traits
Chapter 8 libpmemobj-Cpp: the adaptable language - C++ and persistent memory
