PMDK C++ bindings
1.11.1
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
11 #ifndef LIBPMEMOBJ_CPP_MAKE_PERSISTENT_HPP
12 #define LIBPMEMOBJ_CPP_MAKE_PERSISTENT_HPP
21 #include <libpmemobj/tx_base.h>
48 template <
typename T,
typename... Args>
49 typename detail::pp_if_not_array<T>::type
52 if (pmemobj_tx_stage() != TX_STAGE_WORK)
54 "refusing to allocate memory outside of transaction scope");
57 pmemobj_tx_xalloc(
sizeof(T), detail::type_num<T>(), flag.value);
62 "Failed to allocate persistent memory object")
63 .with_pmemobj_errormsg();
66 "Failed to allocate persistent memory object")
67 .with_pmemobj_errormsg();
70 detail::create<T, Args...>(ptr.
get(), std::forward<Args>(args)...);
90 template <
typename T,
typename... Args>
91 typename std::enable_if<
92 !detail::is_first_arg_same<allocation_flag, Args...>::value,
97 std::forward<Args>(args)...);
117 template <
typename T>
121 if (pmemobj_tx_stage() != TX_STAGE_WORK)
123 "refusing to free memory outside of transaction scope");
132 detail::destroy<T>(*ptr);
134 if (pmemobj_tx_free(*ptr.raw_ptr()) != 0)
136 "failed to delete persistent memory object")
137 .with_pmemobj_errormsg();
element_type * get() const noexcept
Get the direct pointer.
Definition: persistent_ptr.hpp:478
Custom transaction error class.
Definition: pexceptions.hpp:145
Persistent memory namespace.
Definition: allocation_flag.hpp:15
Custom out of memory error class.
Definition: pexceptions.hpp:125
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:119
Persistent_ptr allocation functions for arrays.
Persistent pointer class.
Definition: persistent_ptr.hpp:152
static allocation_flag none()
Do not change allocator behaviour.
Definition: allocation_flag.hpp:61
Functions for destroying arrays.
Type of flag which can be passed to make_persistent.
Definition: allocation_flag.hpp:31
Custom transaction error class.
Definition: pexceptions.hpp:163
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:50
Custom transaction error class.
Definition: pexceptions.hpp:103