PMDK C++ bindings
1.13.0-git107.g7e59f08f
This is the C++ bindings documentation for PMDK's libpmemobj.
|
Persistent self-relative pointer class. More...
#include <libpmemobj++/experimental/self_relative_ptr.hpp>
Public Types | |
using | base_type = self_relative_ptr_base |
using | this_type = self_relative_ptr |
using | element_type = typename pmem::detail::sp_element< T >::type |
using | iterator_category = std::random_access_iterator_tag |
Random access iterator requirements (members) More... | |
using | difference_type = typename base_type::difference_type |
The self_relative_ptr difference type. | |
using | value_type = T |
The type of the value pointed to by the self_relative_ptr. | |
using | reference = T & |
The reference type of the value pointed to by the self_relative_ptr. | |
using | offset_type = OffsetType |
using | byte_type = uint8_t |
using | byte_ptr_type = byte_type * |
using | const_byte_ptr_type = const byte_type * |
Public Member Functions | |
constexpr | self_relative_ptr () noexcept=default |
Default constructor, equal the nullptr. | |
constexpr | self_relative_ptr (std::nullptr_t) noexcept |
Nullptr constructor. | |
self_relative_ptr (element_type *ptr) noexcept | |
Volatile pointer constructor. More... | |
self_relative_ptr (persistent_ptr< T > ptr) noexcept | |
Constructor from persistent_ptr<T> | |
self_relative_ptr (PMEMoid oid) noexcept | |
PMEMoid constructor. More... | |
self_relative_ptr (const self_relative_ptr &ptr) noexcept | |
Copy constructor. | |
template<typename U , typename = typename std::enable_if< !std::is_same< typename std::remove_cv<T>::type, typename std::remove_cv<U>::type>::value && !std::is_void<U>::value, decltype(static_cast<T *>(std::declval<U *>()))>::type> | |
self_relative_ptr (self_relative_ptr< U > const &r) noexcept | |
Copy constructor from a different self_relative_ptr<>. More... | |
element_type * | get () const noexcept |
Get the direct pointer. More... | |
persistent_ptr< T > | to_persistent_ptr () const |
Conversion to persitent ptr. | |
operator bool () const noexcept | |
Bool conversion operator. | |
operator persistent_ptr< T > () const | |
Conversion operator to persistent_ptr. | |
pmem::detail::sp_dereference< T >::type | operator* () const noexcept |
Dereference operator. | |
pmem::detail::sp_member_access< T >::type | operator-> () const noexcept |
Member access operator. | |
template<typename = typename std::enable_if<!std::is_void<T>::value>> | |
pmem::detail::sp_array_access< T >::type | operator[] (difference_type i) const noexcept |
Array access operator. More... | |
self_relative_ptr & | operator= (const self_relative_ptr &r) |
Assignment operator. More... | |
template<typename Y , typename = typename std::enable_if< std::is_convertible<Y *, T *>::value>::type> | |
self_relative_ptr< T > & | operator= (self_relative_ptr< Y > const &r) |
Converting assignment operator from a different self_relative_ptr<>. More... | |
self_relative_ptr & | operator= (std::nullptr_t) |
Nullptr move assignment operator. More... | |
self_relative_ptr< T > & | operator++ () |
Prefix increment operator. | |
self_relative_ptr< T > | operator++ (int) |
Postfix increment operator. | |
self_relative_ptr< T > & | operator-- () |
Prefix decrement operator. | |
self_relative_ptr< T > | operator-- (int) |
Postfix decrement operator. | |
self_relative_ptr< T > & | operator+= (std::ptrdiff_t s) |
Addition assignment operator. | |
self_relative_ptr< T > & | operator-= (std::ptrdiff_t s) |
Subtraction assignment operator. | |
void | swap (self_relative_ptr_base_impl &other) |
Swaps two self_relative_ptr_base objects of the same type. More... | |
byte_ptr_type | to_byte_pointer () const noexcept |
Conversion to byte pointer. | |
void * | to_void_pointer () const noexcept |
Conversion to void*. | |
operator void * () const noexcept | |
Explicit conversion operator to void*. | |
operator byte_ptr_type () const noexcept | |
Explicit conversion operator to byte pointer. | |
bool | is_null () const noexcept |
Fast null checking without conversion to void*. | |
Static Public Member Functions | |
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. | |
Protected Member Functions | |
void | verify_type () |
Verify if element_type is not polymorphic. | |
void * | offset_to_pointer (difference_type other_offset) const noexcept |
Conversion to void* use other offset. | |
difference_type | pointer_to_offset (const self_relative_ptr_base_impl &ptr) const noexcept |
Conversion self_relative_ptr_base to offset from itself. | |
difference_type | pointer_to_offset (void *ptr) const noexcept |
Conversion pointer to offset. | |
Protected Attributes | |
offset_type | offset |
Related Functions | |
(Note that these are not member functions.) | |
template<class T > | |
void | swap (self_relative_ptr< T > &a, self_relative_ptr< T > &b) |
Swaps two self_relative_ptr objects of the same type. More... | |
template<typename T , typename Y > | |
bool | operator== (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept |
Equality operator. | |
template<typename T , typename Y > | |
bool | operator!= (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept |
Inequality operator. | |
template<typename T > | |
bool | operator== (self_relative_ptr< T > const &lhs, std::nullptr_t) noexcept |
Equality operator with nullptr. | |
template<typename T > | |
bool | operator== (std::nullptr_t, self_relative_ptr< T > const &lhs) noexcept |
Equality operator with nullptr. | |
template<typename T > | |
bool | operator!= (self_relative_ptr< T > const &lhs, std::nullptr_t) noexcept |
Inequality operator with nullptr. | |
template<typename T > | |
bool | operator!= (std::nullptr_t, self_relative_ptr< T > const &lhs) noexcept |
Inequality operator with nullptr. | |
template<typename T , typename Y > | |
bool | operator< (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept |
Less than operator. More... | |
template<typename T , typename Y > | |
bool | operator<= (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept |
Less or equal than operator. More... | |
template<typename T , typename Y > | |
bool | operator> (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept |
Greater than operator. More... | |
template<typename T , typename Y > | |
bool | operator>= (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) noexcept |
Greater or equal than operator. More... | |
template<typename T > | |
bool | operator< (self_relative_ptr< T > const &lhs, std::nullptr_t) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator< (std::nullptr_t, self_relative_ptr< T > const &rhs) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator<= (self_relative_ptr< T > const &lhs, std::nullptr_t) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator<= (std::nullptr_t, self_relative_ptr< T > const &rhs) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator> (self_relative_ptr< T > const &lhs, std::nullptr_t) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator> (std::nullptr_t, self_relative_ptr< T > const &rhs) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator>= (self_relative_ptr< T > const &lhs, std::nullptr_t) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
bool | operator>= (std::nullptr_t, self_relative_ptr< T > const &rhs) noexcept |
Compare a self_relative_ptr with a null pointer. | |
template<typename T > | |
self_relative_ptr< T > | operator+ (self_relative_ptr< T > const &lhs, std::ptrdiff_t s) |
Addition operator for self-relative pointers. | |
template<typename T > | |
self_relative_ptr< T > | operator- (self_relative_ptr< T > const &lhs, std::ptrdiff_t s) |
Subtraction operator for self-relative pointers. | |
template<typename T , typename Y , typename = typename std::enable_if< std::is_same<typename std::remove_cv<T>::type, typename std::remove_cv<Y>::type>::value>> | |
ptrdiff_t | operator- (self_relative_ptr< T > const &lhs, self_relative_ptr< Y > const &rhs) |
Subtraction operator for self-relative pointers of identical type. More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &os, self_relative_ptr< T > const &ptr) |
Ostream operator. | |
Persistent self-relative pointer class.
self_relative_ptr implements a smart ptr. It encapsulates the self offsetted pointer and provides member access, dereference and array access operators.
Template parameter type has following requirements:
Casting to self_relative_ptr_base can be easily done from any self_relative_ptr<T> objects, but when casting between convertible objects be advised to use constructors or operator= specified for such conversion, see:
The current version uses an approach where we store offset=real_offset-1 and zero offset (or real_offset equal one) is a null pointer. This is needed to support zero initialization.
using pmem::obj::experimental::self_relative_ptr< T >::iterator_category = std::random_access_iterator_tag |
Random access iterator requirements (members)
The self_relative_ptr iterator category.
|
inlinenoexcept |
Volatile pointer constructor.
ptr | volatile pointer, pointing to persistent memory. |
|
inlinenoexcept |
PMEMoid constructor.
Provided for easy interoperability between C++ and C API's.
oid | C-style persistent pointer |
|
inlinenoexcept |
Copy constructor from a different self_relative_ptr<>.
Available only for convertible, non-void types.
|
inlinenoexcept |
Get the direct pointer.
|
inline |
Assignment operator.
self-relative pointer assignment within a transaction automatically registers this operation so that a rollback is possible.
pmem::transaction_error | when adding the object to the transaction failed. |
|
inline |
Converting assignment operator from a different self_relative_ptr<>.
Available only for convertible types. Just like regular assignment, also automatically registers itself in a transaction.
pmem::transaction_error | when adding the object to the transaction failed. |
|
inline |
Nullptr move assignment operator.
pmem::transaction_error | when adding the object to the transaction failed. |
|
inlinenoexcept |
Array access operator.
Contains run-time bounds checking for static arrays.
|
inlineinherited |
Swaps two self_relative_ptr_base objects of the same type.
[in,out] | other | the other self_relative_ptr to swap. |
|
related |
Subtraction operator for self-relative pointers of identical type.
Calculates the offset difference. Calculating the difference of pointers from objects of different pools is not allowed.
|
related |
Less than operator.
|
related |
Less or equal than operator.
See less than operator for comparison rules.
|
related |
Greater than operator.
See less than operator for comparison rules.
|
related |
Greater or equal than operator.
See less than operator for comparison rules.
|
related |
Swaps two self_relative_ptr objects of the same type.
Non-member swap function as required by Swappable concept. en.cppreference.com/w/cpp/concept/Swappable