PMDK C++ bindings  1.2.0
This is the C++ bindings documentation for PMDK's libpmemobj.
 All Classes Files Functions Variables Typedefs Friends Pages
Public Member Functions | List of all members
pmem::obj::experimental::v< T > Class Template Reference

pmem::obj::experimental::v - volatile resides on pmem class. More...

#include <libpmemobj++/experimental/v.hpp>

Public Member Functions

 v (const T &_val) noexcept
 Value constructor. More...
 
 v () noexcept
 Defaulted constructor.
 
voperator= (const v &rhs)
 Assignment operator.
 
template<typename Y , typename = typename std::enable_if< std::is_convertible<Y, T>::value>::type>
voperator= (const v< Y > &rhs)
 Converting assignment operator from a different v<>. More...
 
T & get () noexcept
 Retrieves reference of the object. More...
 
 operator T () const noexcept
 Conversion operator back to the underlying type.
 
void swap (v &other)
 Swaps two v objects of the same type.
 

Detailed Description

template<typename T>
class pmem::obj::experimental::v< T >

pmem::obj::experimental::v - volatile resides on pmem class.

v class is a property-like template class that has to be used for all volatile variables that reside on persistent memory. This class ensures that the enclosed type is always properly initialized by always calling the class default constructor exactly once per instance of the application. This class has 8 bytes of storage overhead.

#include <fcntl.h>
using namespace pmem::obj;
using namespace pmem::obj::experimental;
void
v_property_example()
{
struct foo {
foo() : counter(10)
{
}
int counter;
};
// pool root structure
struct root {
v<foo> f;
};
// create a pmemobj pool
auto pop = pool<root>::create("poolfile", "layout", PMEMOBJ_MIN_POOL);
auto proot = pop.root();
assert(proot->f.get().counter == 10);
proot->f.get().counter++;
assert(proot->f.get().counter == 11);
}

Constructor & Destructor Documentation

template<typename T>
pmem::obj::experimental::v< T >::v ( const T &  _val)
inlinenoexcept

Value constructor.

Directly assigns a value to the underlying storage.

Parameters
_valconst reference to the value to be assigned.

Member Function Documentation

template<typename T>
T& pmem::obj::experimental::v< T >::get ( )
inlinenoexcept

Retrieves reference of the object.

Returns
a reference to the object.
template<typename T>
template<typename Y , typename = typename std::enable_if< std::is_convertible<Y, T>::value>::type>
v& pmem::obj::experimental::v< T >::operator= ( const v< Y > &  rhs)
inline

Converting assignment operator from a different v<>.

Available only for convertible types.


The documentation for this class was generated from the following file: