pstore2
Public Types | Public Member Functions | List of all members
pstore::maybe< T, typename > Class Template Reference

Public Types

using value_type = T
 

Public Member Functions

constexpr maybe () noexcept=default
 Constructs an object that does not contain a value.
 
template<typename U , typename = typename std::enable_if< std::is_constructible<T, U &&>::value && !std::is_same<typename details::remove_cvref_t<U>, maybe<T>>::value>::type>
 maybe (U &&value) noexcept(std::is_nothrow_move_constructible< T >::value &&std::is_nothrow_copy_constructible< T >::value &&!std::is_convertible< U &&, T >::value)
 Constructs an optional object that contains a value, initialized with the expression std::forward<U>(value). More...
 
template<typename... Args>
 maybe (in_place_t const inp, Args &&... args)
 
 maybe (maybe const &other) noexcept(std::is_nothrow_copy_constructible< T >::value)
 Copy constructor: If other contains a value, initializes the contained value with the expression *other. More...
 
 maybe (maybe &&other) noexcept(std::is_nothrow_move_constructible< T >::value)
 Move constructor: If other contains a value, initializes the contained value with the expression std::move(*other) and does not make other empty: a moved-from optional still contains a value, but the value itself is moved from. More...
 
void reset () noexcept
 If *this contains a value, destroy it. *this does not contain a value after this call.
 
maybeoperator= (maybe const &other) noexcept(std::is_nothrow_copy_assignable< T >::value &&std::is_nothrow_copy_constructible< T >::value)
 
maybeoperator= (maybe &&other) noexcept(std::is_nothrow_move_assignable< T >::value &&std::is_nothrow_move_constructible< T >::value)
 
template<typename U , typename = typename std::enable_if< std::is_constructible<T, U &&>::value && !std::is_same<typename details::remove_cvref_t<U>, maybe<T>>::value>::type>
maybeoperator= (U &&other) noexcept(std::is_nothrow_copy_assignable< T >::value &&std::is_nothrow_copy_constructible< T >::value &&std::is_nothrow_move_assignable< T >::value &&std::is_nothrow_move_constructible< T >::value)
 
template<typename... Args>
T & emplace (Args &&... args)
 Constructs the contained value in-place. More...
 
bool operator== (maybe const &other) const
 
bool operator!= (maybe const &other) const
 
T const & operator* () const noexcept
 accesses the contained value
 
T & operator* () noexcept
 accesses the contained value
 
T const * operator-> () const noexcept
 accesses the contained value
 
T * operator-> () noexcept
 accesses the contained value
 
constexpr operator bool () const noexcept
 checks whether the object contains a value
 
constexpr bool has_value () const noexcept
 checks whether the object contains a value
 
T const & value () const noexcept
 
T & value () noexcept
 
template<typename U >
constexpr T value_or (U &&default_value) const
 

Constructor & Destructor Documentation

◆ maybe() [1/3]

template<typename T, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
template<typename U , typename = typename std::enable_if< std::is_constructible<T, U &&>::value && !std::is_same<typename details::remove_cvref_t<U>, maybe<T>>::value>::type>
pstore::maybe< T, typename >::maybe ( U &&  value)
inlineexplicitnoexcept

Constructs an optional object that contains a value, initialized with the expression std::forward<U>(value).

◆ maybe() [2/3]

template<typename T, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
pstore::maybe< T, typename >::maybe ( maybe< T, typename > const &  other)
inlinenoexcept

Copy constructor: If other contains a value, initializes the contained value with the expression *other.

If other does not contain a value, constructs an object that does not contain a value.

◆ maybe() [3/3]

template<typename T, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
pstore::maybe< T, typename >::maybe ( maybe< T, typename > &&  other)
inlinenoexcept

Move constructor: If other contains a value, initializes the contained value with the expression std::move(*other) and does not make other empty: a moved-from optional still contains a value, but the value itself is moved from.

If other does not contain a value, constructs an object that does not contain a value.

Member Function Documentation

◆ emplace()

template<typename T, typename = typename std::enable_if<!std::is_reference<T>::value>::type>
template<typename... Args>
T& pstore::maybe< T, typename >::emplace ( Args &&...  args)
inline

Constructs the contained value in-place.

If *this already contains a value before the call, the contained value is destroyed by calling its destructor.

args... The arguments to pass to the constructor

Returns
A reference to the new contained value.

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