|
(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.
|
|
template<typename T>
class pmem::obj::experimental::self_relative_ptr< T >
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:
Even if all of the above requirements are met, type representation may vary depending on ABI and compiler optimizations (as stated in [class.mem]: "the order of allocation of non-static data members with different access control is unspecified"). To enforce the same layout for all ABIs and optimization levels type should satisfy StandardLayoutType requirement.If pointer is used with array type, additional requirement is:
- Element type must be default constructible
The pointer is not designed to work with polymorphic types, as they have runtime RTTI info embedded, which is implementation specific and thus not consistently rebuildable. Such constructs as polymorphic members or members of a union defined within a class held in a pointer will also yield undefined behavior.C++ standard states that lifetime of an object is a runtime property [basic.lifetime]. Conditions which must be fulfilled for object's lifetime to begin, imply that using any non-trivially constructible object with pointer is undefined behaviour. This is being partially addressed by the following proposal:
https://groups.google.com/a/isocpp.org/forum/#!topic/std-proposals/bk8esqk-QooAnother caveat is that snapshotting elements in a transaction and performing rollback uses memcpy internally. Using memcpy on an object in C++ is allowed by the standard only if the type satisfies TriviallyCopyable requirement.
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.
- real_offset = pointer - this;
- pointer = real_offset + this;
- or pointer = offset + this + 1;