40 #ifndef LIBPMEMOBJ_CPP_MAKE_PERSISTENT_HPP 41 #define LIBPMEMOBJ_CPP_MAKE_PERSISTENT_HPP 49 #include <libpmemobj/tx_base.h> 76 template <
typename T,
typename... Args>
77 typename detail::pp_if_not_array<T>::type
80 if (pmemobj_tx_stage() != TX_STAGE_WORK)
82 "refusing to allocate memory outside of transaction scope");
85 pmemobj_tx_xalloc(
sizeof(T), detail::type_num<T>(), flag.value);
89 "failed to allocate persistent memory object");
91 detail::create<T, Args...>(ptr.
get(), std::forward<Args>(args)...);
111 template <
typename T,
typename... Args>
112 typename std::enable_if<
118 std::forward<Args>(args)...);
135 template <
typename T>
139 if (pmemobj_tx_stage() != TX_STAGE_WORK)
141 "refusing to free memory outside of transaction scope");
150 detail::destroy<T>(*ptr);
152 if (pmemobj_tx_free(*ptr.raw_ptr()) != 0)
154 "failed to delete persistent memory object");
Custom transaction error class.
Definition: pexceptions.hpp:84
Persistent pointer class.
Definition: common.hpp:110
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:137
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:78
Functions for destroying arrays.
Commonly used functionality.
Compile time type check for make_persistent.
Type of flag which can be passed to make_persistent.
Definition: allocation_flag.hpp:60
Helper functionality for handling variadic templates.
allocation_flag - defines flags which can be passed to make_persistent
Custom transaction error class.
Definition: pexceptions.hpp:94
Custom transaction error class.
Definition: pexceptions.hpp:104
Definition: allocation_flag.hpp:43
element_type * get() const noexcept
Get a direct pointer.
Definition: persistent_ptr_base.hpp:286
static allocation_flag none()
Do not change allocator behaviour.
Definition: allocation_flag.hpp:90