Bond
 
Loading...
Searching...
No Matches
bond::detail::maybe_common< T > Class Template Reference
Inheritance diagram for bond::detail::maybe_common< T >:
bond::maybe< T, typename boost::disable_if< detail::has_allocator< T > >::type > bond::maybe< T, typename boost::enable_if< detail::has_allocator< T > >::type >

Public Types

using value_type = T
 The type of the value that may be inside the maybe. More...
 

Public Member Functions

bool is_nothing () const BOND_NOEXCEPT
 Check if this object contains nothing. More...
 
 operator bool () const BOND_NOEXCEPT
 Check if this object contains a value. More...
 
void set_nothing () BOND_NOEXCEPT
 Set to nothing. More...
 
template<typename... Args>
T & emplace (Args &&... args)
 Construct a value in place. More...
 
T & value ()
 Get a reference to the value. More...
 
const T & value () const
 Get a constant reference to the value. More...
 
T & value (const std::nothrow_t &) BOND_NOEXCEPT
 Get a reference to the value. More...
 
const T & value (const std::nothrow_t &) const BOND_NOEXCEPT
 Get a constant reference to the value. More...
 
maybe_commonoperator= (const maybe_common &)=default
 Assign from another maybe. More...
 
maybe_commonoperator= (maybe_common &&)=default
 Move assign from another maybe. More...
 

Friends

bool operator== (const maybe_common &lhs, const T &rhs)
 Compares a maybe and a value for equality. More...
 
bool operator!= (const maybe_common &lhs, const T &rhs)
 Compares a maybe and a value for inequality. More...
 
bool operator== (const T &lhs, const maybe_common &rhs)
 Compares a value and a maybe for equality. More...
 
bool operator!= (const T &lhs, const maybe_common &rhs)
 Compares and a value and a maybe for inequality. More...
 

Detailed Description

template<typename T>
class bond::detail::maybe_common< T >

Internal base class with shared implementation between the two maybe variants. Consult the documentation for bond::maybe<T> for its public interface.

Member Typedef Documentation

◆ value_type

template<typename T >
using bond::detail::maybe_common< T >::value_type = T

The type of the value that may be inside the maybe.

Member Function Documentation

◆ emplace()

template<typename T >
template<typename... Args>
T & bond::detail::maybe_common< T >::emplace ( Args &&...  args)

Construct a value in place.

Since
8.0.0

◆ is_nothing()

template<typename T >
bool bond::detail::maybe_common< T >::is_nothing ( ) const

Check if this object contains nothing.

Returns
true if this holds nothing; otherwise false.

◆ operator bool()

template<typename T >
bond::detail::maybe_common< T >::operator bool ( ) const
explicit

Check if this object contains a value.

Returns
true if this object holds a value; otherwise false.
Since
8.0.0

◆ operator=() [1/2]

template<typename T >
maybe_common & bond::detail::maybe_common< T >::operator= ( const maybe_common< T > &  )
default

Assign from another maybe.

◆ operator=() [2/2]

template<typename T >
maybe_common & bond::detail::maybe_common< T >::operator= ( maybe_common< T > &&  )
default

Move assign from another maybe.

◆ set_nothing()

template<typename T >
void bond::detail::maybe_common< T >::set_nothing ( )

Set to nothing.

◆ value() [1/4]

template<typename T >
T & bond::detail::maybe_common< T >::value ( )

Get a reference to the value.

Exceptions
CoreExceptionif the object contains nothing

◆ value() [2/4]

template<typename T >
const T & bond::detail::maybe_common< T >::value ( ) const

Get a constant reference to the value.

Exceptions
CoreExceptionif the object contains nothing

◆ value() [3/4]

template<typename T >
T & bond::detail::maybe_common< T >::value ( const std::nothrow_t &  )

Get a reference to the value.

Will never throw, but has undefined behavior if the object contains nothing.

Since
8.0.0

◆ value() [4/4]

template<typename T >
const T & bond::detail::maybe_common< T >::value ( const std::nothrow_t &  ) const

Get a constant reference to the value.

Will never throw, but has undefined behavior if the object contains nothing.

Since
8.0.0

Friends And Related Function Documentation

◆ operator!= [1/2]

template<typename T >
bool operator!= ( const maybe_common< T > &  lhs,
const T &  rhs 
)
friend

Compares a maybe and a value for inequality.

See operator==(const maybe_common&,const T&) for details about how maybes holding nothing are handled.

Since
8.0.0

◆ operator!= [2/2]

template<typename T >
bool operator!= ( const T &  lhs,
const maybe_common< T > &  rhs 
)
friend

Compares and a value and a maybe for inequality.

See operator==(const T&,const maybe_common&) for details about how maybes holding nothing are handled.

Since
8.0.0

◆ operator== [1/2]

template<typename T >
bool operator== ( const maybe_common< T > &  lhs,
const T &  rhs 
)
friend

Compares a maybe and a value for equality.

Returns
false if the maybe holds nothing; otherwise, calls operator== with the maybe's value and the provided value.
Since
8.0.0

◆ operator== [2/2]

template<typename T >
bool operator== ( const T &  lhs,
const maybe_common< T > &  rhs 
)
friend

Compares a value and a maybe for equality.

Returns
false if the maybe holds nothing; otherwise, calls operator== with the provided value and maybe's value.
Since
8.0.0