PMDK C++ bindings
1.11.1
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
9 #ifndef LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_BASE_IMPL_HPP
10 #define LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_BASE_IMPL_HPP
13 #include <type_traits>
38 template <
typename OffsetType>
42 using difference_type = std::ptrdiff_t;
43 using offset_type = OffsetType;
44 using byte_type = uint8_t;
45 using byte_ptr_type = byte_type *;
46 using const_byte_ptr_type =
const byte_type *;
56 : offset(nullptr_offset)
64 : offset(nullptr_offset)
104 detail::conditional_add_to_tx(
this);
118 detail::conditional_add_to_tx(
this);
133 detail::conditional_add_to_tx(
this);
134 detail::conditional_add_to_tx(&other);
162 explicit operator void *()
const noexcept
170 explicit operator byte_ptr_type() const noexcept
178 static difference_type
191 return offset == nullptr_offset;
223 uintptr_t mask = other_offset == nullptr_offset;
225 uintptr_t ptr =
static_cast<uintptr_t
>(
226 reinterpret_cast<intptr_t
>(
this) + other_offset + 1);
228 return reinterpret_cast<void *
>(ptr);
247 uintptr_t mask = ptr.is_null();
249 difference_type distance_between_self =
250 reinterpret_cast<const_byte_ptr_type
>(&ptr) -
251 reinterpret_cast<const_byte_ptr_type
>(
this);
252 distance_between_self &=
253 reinterpret_cast<difference_type &
>(mask);
254 return ptr.offset + distance_between_self;
274 uintptr_t mask = ptr ==
nullptr;
276 difference_type new_offset =
static_cast<byte_ptr_type
>(ptr) -
277 reinterpret_cast<const_byte_ptr_type
>(
this) - 1;
278 new_offset &=
reinterpret_cast<difference_type &
>(mask);
286 static constexpr difference_type nullptr_offset = 0;
288 template <
typename T>
295 template <
typename T>
299 using difference_type =
typename access_type::difference_type;
301 template <
typename Po
interType>
302 static difference_type
303 pointer_to_offset(
const access_type &obj, PointerType *ptr)
308 template <
typename Po
interType>
310 offset_to_pointer(difference_type offset,
const access_type &obj)
313 return static_cast<PointerType *
>(ptr);
difference_type pointer_to_offset(void *ptr) const noexcept
Conversion pointer to offset.
Definition: self_relative_ptr_base_impl.hpp:261
Persistent memory namespace.
Definition: allocation_flag.hpp:15
void swap(self_relative_ptr_base_impl &other)
Swaps two self_relative_ptr_base objects of the same type.
Definition: self_relative_ptr_base_impl.hpp:129
void * to_void_pointer() const noexcept
Conversion to void*.
Definition: self_relative_ptr_base_impl.hpp:154
Commonly used functionality.
self_relative_ptr_base_impl(difference_type offset) noexcept
Offset constructor.
Definition: self_relative_ptr_base_impl.hpp:200
self_relative_ptr_base_impl(self_relative_ptr_base_impl const &r) noexcept
Copy constructor.
Definition: self_relative_ptr_base_impl.hpp:83
static difference_type distance_between(const self_relative_ptr_base_impl &first, const self_relative_ptr_base_impl &second)
Byte distance between two relative pointers.
Definition: self_relative_ptr_base_impl.hpp:179
bool is_null() const noexcept
Fast null checking without conversion to void*.
Definition: self_relative_ptr_base_impl.hpp:189
Helper template for persistent ptr specialization.
constexpr self_relative_ptr_base_impl(std::nullptr_t) noexcept
Nullptr constructor.
Definition: self_relative_ptr_base_impl.hpp:63
self_relative_ptr_base_impl & operator=(std::nullptr_t &&)
Nullptr move assignment operator.
Definition: self_relative_ptr_base_impl.hpp:116
byte_ptr_type to_byte_pointer() const noexcept
Conversion to byte pointer.
Definition: self_relative_ptr_base_impl.hpp:145
Static class accesssor to self_relative_ptr_base.
Definition: self_relative_ptr_base_impl.hpp:296
self_relative_ptr_base_impl(void *ptr) noexcept
Volatile pointer constructor.
Definition: self_relative_ptr_base_impl.hpp:73
void * offset_to_pointer(difference_type other_offset) const noexcept
Conversion to void* use other offset.
Definition: self_relative_ptr_base_impl.hpp:209
self_relative_ptr base template class
Definition: self_relative_ptr_base_impl.hpp:39
difference_type pointer_to_offset(const self_relative_ptr_base_impl &ptr) const noexcept
Conversion self_relative_ptr_base to offset from itself.
Definition: self_relative_ptr_base_impl.hpp:235
self_relative_ptr_base_impl & operator=(self_relative_ptr_base_impl const &r)
Assignment operator.
Definition: self_relative_ptr_base_impl.hpp:100
constexpr self_relative_ptr_base_impl() noexcept
Default constructor, equal the nullptr.
Definition: self_relative_ptr_base_impl.hpp:55