PMDK C++ bindings
1.9
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
40 #ifndef LIBPMEMOBJ_CPP_MAKE_PERSISTENT_HPP
41 #define LIBPMEMOBJ_CPP_MAKE_PERSISTENT_HPP
50 #include <libpmemobj/tx_base.h>
77 template <
typename T,
typename... Args>
78 typename detail::pp_if_not_array<T>::type
81 if (pmemobj_tx_stage() != TX_STAGE_WORK)
83 "refusing to allocate memory outside of transaction scope");
86 pmemobj_tx_xalloc(
sizeof(T), detail::type_num<T>(), flag.value);
91 "Failed to allocate persistent memory object")
92 .with_pmemobj_errormsg();
95 "Failed to allocate persistent memory object")
96 .with_pmemobj_errormsg();
99 detail::create<T, Args...>(ptr.
get(), std::forward<Args>(args)...);
119 template <
typename T,
typename... Args>
120 typename std::enable_if<
121 !detail::is_first_arg_same<allocation_flag, Args...>::value,
126 std::forward<Args>(args)...);
146 template <
typename T>
150 if (pmemobj_tx_stage() != TX_STAGE_WORK)
152 "refusing to free memory outside of transaction scope");
161 detail::destroy<T>(*ptr);
163 if (pmemobj_tx_free(*ptr.raw_ptr()) != 0)
165 "failed to delete persistent memory object")
166 .with_pmemobj_errormsg();
element_type * get() const noexcept
Get the direct pointer.
Definition: persistent_ptr.hpp:538
Custom transaction error class.
Definition: pexceptions.hpp:169
Persistent memory namespace.
Definition: allocation_flag.hpp:44
Custom out of memory error class.
Definition: pexceptions.hpp:149
Commonly used functionality.
Compile time type check for make_persistent.
void delete_persistent(typename detail::pp_if_not_array< T >::type ptr)
Transactionally free an object of type T held in a persistent_ptr.
Definition: make_persistent.hpp:148
Persistent_ptr allocation functions for arrays.
Persistent pointer class.
Definition: persistent_ptr.hpp:212
static allocation_flag none()
Do not change allocator behaviour.
Definition: allocation_flag.hpp:90
Functions for destroying arrays.
Type of flag which can be passed to make_persistent.
Definition: allocation_flag.hpp:60
Custom transaction error class.
Definition: pexceptions.hpp:187
Helper functionality for handling variadic templates.
allocation_flag - defines flags which can be passed to make_persistent
detail::pp_if_not_array< T >::type make_persistent(allocation_flag flag, Args &&... args)
Transactionally allocate and construct an object of type T.
Definition: make_persistent.hpp:79
Custom transaction error class.
Definition: pexceptions.hpp:130