PMDK C++ bindings
1.11
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Go to the documentation of this file.
9 #ifndef LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_HPP
10 #define LIBPMEMOBJ_CPP_SELF_RELATIVE_PTR_HPP
15 #include <type_traits>
21 namespace experimental
48 using element_type =
typename pmem::detail::sp_element<T>::type;
62 using difference_type =
typename base_type::difference_type;
118 static_cast<element_type *
>(pmemobj_direct(oid))))
137 typename =
typename std::enable_if<
139 typename std::remove_cv<T>::type,
140 typename std::remove_cv<U>::type>::value &&
141 !std::is_void<U>::value,
142 decltype(
static_cast<T *
>(std::declval<U *>()))>::type>
158 inline element_type *
161 return static_cast<element_type *
>(
181 explicit operator bool() const noexcept
197 typename pmem::detail::sp_dereference<T>::type
operator*() const
200 return *(this->
get());
206 typename pmem::detail::sp_member_access<T>::type
operator->() const
217 template <typename = typename std::enable_if<!std::is_void<T>::value>>
218 typename pmem::detail::sp_array_access<T>::type
222 (i < pmem::detail::sp_extent<T>::value ||
223 pmem::detail::sp_extent<T>::value == 0) &&
224 "persistent array index out of bounds");
226 return this->
get()[i];
257 template <
typename Y,
258 typename =
typename std::enable_if<
259 std::is_convertible<Y *, T *>::value>::type>
275 detail::conditional_add_to_tx(
this);
276 this->offset = self_offset(
nullptr);
286 detail::conditional_add_to_tx(
this);
287 this->offset +=
static_cast<difference_type
>(
sizeof(T));
310 detail::conditional_add_to_tx(
this);
311 this->offset -=
static_cast<difference_type
>(
sizeof(T));
334 detail::conditional_add_to_tx(
this);
335 this->offset += s *
static_cast<difference_type
>(
sizeof(T));
345 detail::conditional_add_to_tx(
this);
346 this->offset -= s *
static_cast<difference_type
>(
sizeof(T));
357 static_assert(!std::is_polymorphic<element_type>::value,
358 "Polymorphic types are not supported");
363 self_offset(element_type *ptr)
const noexcept
385 template <
typename T,
typename Y>
390 return lhs.to_byte_pointer() == rhs.to_byte_pointer();
396 template <
typename T,
typename Y>
401 return !(lhs == rhs);
407 template <
typename T>
417 template <
typename T>
427 template <
typename T>
437 template <
typename T>
450 template <
typename T,
typename Y>
455 return lhs.to_byte_pointer() < rhs.to_byte_pointer();
463 template <
typename T,
typename Y>
476 template <
typename T,
typename Y>
489 template <
typename T,
typename Y>
502 template <
typename T>
506 return std::less<typename self_relative_ptr<T>::element_type *>()(
513 template <
typename T>
517 return std::less<typename self_relative_ptr<T>::element_type *>()(
524 template <
typename T>
528 return !(
nullptr < lhs);
534 template <
typename T>
538 return !(rhs <
nullptr);
544 template <
typename T>
548 return nullptr < lhs;
554 template <
typename T>
558 return rhs <
nullptr;
564 template <
typename T>
568 return !(lhs <
nullptr);
574 template <
typename T>
578 return !(
nullptr < rhs);
584 template <
typename T>
585 inline self_relative_ptr<T>
596 template <
typename T>
597 inline self_relative_ptr<T>
612 template <
typename T,
typename Y,
613 typename =
typename std::enable_if<
614 std::is_same<typename std::remove_cv<T>::type,
615 typename std::remove_cv<Y>::type>::value>>
620 static_cast<ptrdiff_t
>(
sizeof(T));
626 template <
typename T>
self_relative_ptr< T > operator-(self_relative_ptr< T > const &lhs, std::ptrdiff_t s)
Subtraction operator for self-relative pointers.
Definition: self_relative_ptr.hpp:598
self_relative_ptr & operator=(std::nullptr_t)
Nullptr move assignment operator.
Definition: self_relative_ptr.hpp:273
list_node_type value_type
The type of the value pointed to by the self_relative_ptr.
Definition: self_relative_ptr.hpp:67
bool operator>=(self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept
Greater or equal than operator.
Definition: self_relative_ptr.hpp:491
self_relative_ptr< T > & operator++()
Prefix increment operator.
Definition: self_relative_ptr.hpp:284
self_relative_ptr< T > operator++(int)
Postfix increment operator.
Definition: self_relative_ptr.hpp:296
self_relative_ptr< T > operator--(int)
Postfix decrement operator.
Definition: self_relative_ptr.hpp:320
element_type * get() const noexcept
Get the direct pointer.
Definition: self_relative_ptr.hpp:159
typename base_type::difference_type difference_type
The self_relative_ptr difference type.
Definition: self_relative_ptr.hpp:62
self_relative_ptr< T > & operator-=(std::ptrdiff_t s)
Subtraction assignment operator.
Definition: self_relative_ptr.hpp:343
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
self_relative_ptr(persistent_ptr< T > ptr) noexcept
Constructor from persistent_ptr<T>
Definition: self_relative_ptr.hpp:104
Persistent self-relative pointer class.
Definition: self_relative_ptr.hpp:44
self_relative_ptr< T > & operator--()
Prefix decrement operator.
Definition: self_relative_ptr.hpp:308
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
pmem::detail::sp_dereference< T >::type operator*() const noexcept
Dereference operator.
Definition: self_relative_ptr.hpp:197
self_relative_ptr(PMEMoid oid) noexcept
PMEMoid constructor.
Definition: self_relative_ptr.hpp:116
pmem::detail::sp_array_access< T >::type operator[](difference_type i) const noexcept
Array access operator.
Definition: self_relative_ptr.hpp:219
self_relative_ptr(self_relative_ptr< U > const &r) noexcept
Copy constructor from a different self_relative_ptr<>.
Definition: self_relative_ptr.hpp:143
bool operator<=(self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept
Less or equal than operator.
Definition: self_relative_ptr.hpp:465
persistent_ptr< T > to_persistent_ptr() const
Conversion to persitent ptr.
Definition: self_relative_ptr.hpp:169
bool operator<(self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept
Less than operator.
Definition: self_relative_ptr.hpp:452
self_relative_ptr & operator=(const self_relative_ptr &r)
Assignment operator.
Definition: self_relative_ptr.hpp:240
bool is_null() const noexcept
Fast null checking without conversion to void*.
Definition: self_relative_ptr_base_impl.hpp:189
self_relative_ptr(const self_relative_ptr &ptr) noexcept
Copy constructor.
Definition: self_relative_ptr.hpp:125
self_relative_ptr(element_type *ptr) noexcept
Volatile pointer constructor.
Definition: self_relative_ptr.hpp:96
Helper template for persistent ptr specialization.
void swap(concurrent_map< Key, Value, Comp, Allocator > &lhs, concurrent_map< Key, Value, Comp, Allocator > &rhs)
Non-member swap.
Definition: concurrent_map.hpp:151
Persistent pointer class.
Definition: persistent_ptr.hpp:152
self_relative_ptr< T > & operator=(self_relative_ptr< Y > const &r)
Converting assignment operator from a different self_relative_ptr<>.
Definition: self_relative_ptr.hpp:261
pmem::detail::sp_member_access< T >::type operator->() const noexcept
Member access operator.
Definition: self_relative_ptr.hpp:206
bool operator!=(self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept
Inequality operator.
Definition: self_relative_ptr.hpp:398
constexpr self_relative_ptr() noexcept=default
Default constructor, equal the nullptr.
bool operator==(self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept
Equality operator.
Definition: self_relative_ptr.hpp:387
std::random_access_iterator_tag iterator_category
Random access iterator requirements (members)
Definition: self_relative_ptr.hpp:57
self_relative_ptr< T > operator+(self_relative_ptr< T > const &lhs, std::ptrdiff_t s)
Addition operator for self-relative pointers.
Definition: self_relative_ptr.hpp:586
void verify_type()
Verify if element_type is not polymorphic.
Definition: self_relative_ptr.hpp:355
bool operator>(self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept
Greater than operator.
Definition: self_relative_ptr.hpp:478
pmem::detail::self_relative_ptr_base_impl< std::ptrdiff_t > self_relative_ptr_base
self_relative_ptr base (non-template) class
Definition: self_relative_ptr_base.hpp:36
std::ostream & operator<<(std::ostream &os, const radix_tree< K, V, BV > &tree)
Prints tree in DOT format.
Definition: radix_tree.hpp:2404
Persistent smart pointer.
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
self_relative_ptr< T > & operator+=(std::ptrdiff_t s)
Addition assignment operator.
Definition: self_relative_ptr.hpp:332
list_node_type & reference
The reference type of the value pointed to by the self_relative_ptr.
Definition: self_relative_ptr.hpp:72
Base class for self_relative_ptr.