PMEMKV  1.4.1-git1.g7db5b8f
This is the C++ documentation for PMEMKV.
Public Member Functions | Private Attributes | List of all members
pmem::kv::result< T > Class Template Reference

Stores result of an operation. It always contains status and optionally can contain value. More...

#include <libpmemkv.hpp>

Public Member Functions

 result (const T &val) noexcept(noexcept(T(std::declval< T >())))
 Creates result with value (status is automatically initialized to status::OK). More...
 
 result (const status &err) noexcept
 Creates result which contains only status. More...
 
 result (const result &other) noexcept(noexcept(T(std::declval< T >())))
 Default copy constructor. More...
 
 result (result &&other) noexcept(noexcept(T(std::declval< T >())))
 Default move constructor. More...
 
 result (T &&val) noexcept(noexcept(T(std::declval< T >())))
 Constructor with rvalue reference to T. More...
 
 ~result ()
 Explicit destructor. More...
 
resultoperator= (const result &other) noexcept(noexcept(std::declval< T >().~T()) &&noexcept(T(std::declval< T >())))
 Default copy assignment operator. More...
 
resultoperator= (result &&other) noexcept(noexcept(std::declval< T >().~T()) &&noexcept(T(std::declval< T >())))
 Default move assignment operator. More...
 
bool is_ok () const noexcept
 Checks if the result contains value (status == status::OK). More...
 
const T & get_value () const &
 Returns const reference to value from the result. More...
 
T & get_value () &
 Returns reference to value from the result. More...
 
T && get_value () &&
 Returns rvalue reference to value from the result. More...
 
status get_status () const noexcept
 Returns status from the result. More...
 

Private Attributes

union {
   T   value
 
}; 
 
status s
 

Detailed Description

template<typename T>
class pmem::kv::result< T >

Stores result of an operation. It always contains status and optionally can contain value.

If result contains value: is_ok() returns true, get_value() returns value, get_status() returns status::OK.

If result contains error: is_ok() returns false, get_value() throws bad_result_access, get_status() returns status other than status::OK.

Constructor & Destructor Documentation

◆ result() [1/5]

template<typename T >
pmem::kv::result< T >::result ( const T &  val)
noexcept

Creates result with value (status is automatically initialized to status::OK).

Parameters
[in]valvalue.

◆ result() [2/5]

template<typename T >
pmem::kv::result< T >::result ( const status status)
noexcept

Creates result which contains only status.

Parameters
[in]statusstatus other than status::OK.

◆ result() [3/5]

template<typename T >
pmem::kv::result< T >::result ( const result< T > &  other)
noexcept

Default copy constructor.

Parameters
[in]otherresult to copy.

◆ result() [4/5]

template<typename T >
pmem::kv::result< T >::result ( result< T > &&  other)
noexcept

Default move constructor.

Parameters
[in]otherresult to move.

◆ result() [5/5]

template<typename T >
pmem::kv::result< T >::result ( T &&  val)
noexcept

Constructor with rvalue reference to T.

Parameters
[in]valrvalue reference to T

◆ ~result()

template<typename T >
pmem::kv::result< T >::~result

Explicit destructor.

Member Function Documentation

◆ get_status()

template<typename T >
status pmem::kv::result< T >::get_status
noexcept

Returns status from the result.

It returns status::OK if there is a value, and other status (with the appropriate 'error') if there isn't any value.

Returns
status

◆ get_value() [1/3]

template<typename T >
T & pmem::kv::result< T >::get_value ( ) &

Returns reference to value from the result.

If result doesn't contain value, throws bad_result_access.

Exceptions
bad_result_access
Returns
reference to value from the result

◆ get_value() [2/3]

template<typename T >
T && pmem::kv::result< T >::get_value ( ) &&

Returns rvalue reference to value from the result.

If result doesn't contain value, throws bad_result_access.

Exceptions
bad_result_access
Returns
rvalue reference to value from the result

◆ get_value() [3/3]

template<typename T >
const T & pmem::kv::result< T >::get_value ( ) const &

Returns const reference to value from the result.

If result doesn't contain value, throws bad_result_access.

Exceptions
bad_result_access
Returns
const reference to value from the result.

◆ is_ok()

template<typename T >
bool pmem::kv::result< T >::is_ok
noexcept

Checks if the result contains value (status == status::OK).

Returns
bool

◆ operator=() [1/2]

template<typename T >
result< T > & pmem::kv::result< T >::operator= ( const result< T > &  other)
noexcept

Default copy assignment operator.

Parameters
[in]otherresult to copy.

◆ operator=() [2/2]

template<typename T >
result< T > & pmem::kv::result< T >::operator= ( result< T > &&  other)
noexcept

Default move assignment operator.

Parameters
[in]otherresult to move.

Member Data Documentation

◆ @1

union { ... }

◆ s

template<typename T >
status pmem::kv::result< T >::s
private

◆ value

template<typename T >
T pmem::kv::result< T >::value

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