staticlib_support  1.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Public Member Functions | List of all members
staticlib::support::optional< T > Class Template Reference

Basic implementation of optional, reference impl ( https://github.com/akrzemi1/Optional ) cannot be used, as it doesn't support MSVC2013. More...

#include <staticlib/support/optional.hpp>

Public Member Functions

 optional ()
 Constructs empty instance.
 optional (T &&value)
 Constructor.
 optional (const optional &)
 Deleted copy constructor.
optional & operator= (const optional &)
 Deleted copy assignment operator.
 optional (optional &&other) STATICLIB_NOEXCEPT
 Move constructor.
optional & operator= (optional &&other) STATICLIB_NOEXCEPT
 Move assignment operator.
 ~optional () STATICLIB_NOEXCEPT
 Destructor.
 operator bool () const
 Overloaded bool operator.
bool has_value () const
 Check whether this instance stores value.
T & value ()
 Access stored value.
const T & value () const
 Access stored value.
T value_or (T &&default_value) const
 Access stored value; value will be copied out.
T value_or (T &&default_value)
 Access stored value; value will be moved out of this instance and remaining value will be in "valid, but unspecified state".
void reset ()
 Destructs stored value if any.

Detailed Description

template<typename T>
class staticlib::support::optional< T >

Basic implementation of optional, reference impl ( https://github.com/akrzemi1/Optional ) cannot be used, as it doesn't support MSVC2013.

Constructor & Destructor Documentation

template<typename T >
staticlib::support::optional< T >::optional ( )
inline

Constructs empty instance.

template<typename T >
staticlib::support::optional< T >::optional ( T &&  value)
inlineexplicit

Constructor.

Parameters
valueto store in this instance
template<typename T >
staticlib::support::optional< T >::optional ( const optional< T > &  )

Deleted copy constructor.

template<typename T >
staticlib::support::optional< T >::optional ( optional< T > &&  other)
inline

Move constructor.

Parameters
otherother instance
template<typename T >
staticlib::support::optional< T >::~optional ( )
inline

Destructor.

Member Function Documentation

template<typename T >
bool staticlib::support::optional< T >::has_value ( ) const
inline

Check whether this instance stores value.

Returns
true if this instance stores value, false otherwise
template<typename T >
staticlib::support::optional< T >::operator bool ( ) const
inlineexplicit

Overloaded bool operator.

Returns
true if this instance stores value, false otherwise
template<typename T >
optional& staticlib::support::optional< T >::operator= ( const optional< T > &  )

Deleted copy assignment operator.

template<typename T >
optional& staticlib::support::optional< T >::operator= ( optional< T > &&  other)
inline

Move assignment operator.

Parameters
otherother instance
Returns
this instance
template<typename T >
void staticlib::support::optional< T >::reset ( )
inline

Destructs stored value if any.

template<typename T >
T& staticlib::support::optional< T >::value ( )
inline

Access stored value.

Returns
value reference
Exceptions
bad_optional_access_exceptionof this instance is empty
template<typename T >
const T& staticlib::support::optional< T >::value ( ) const
inline

Access stored value.

Returns
value const reference
Exceptions
bad_optional_access_exceptionof this instance is empty
template<typename T >
T staticlib::support::optional< T >::value_or ( T &&  default_value) const
inline

Access stored value; value will be copied out.

Parameters
default_valuedefault value
Returns
stored value if has one, default value otherwise
template<typename T >
T staticlib::support::optional< T >::value_or ( T &&  default_value)
inline

Access stored value; value will be moved out of this instance and remaining value will be in "valid, but unspecified state".

Parameters
default_valuedefault value
Returns
stored value if has one, default value otherwise

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