Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Optional Values

template <class T>
class optional
{
public :

    typedef T         value_type ;
    typedef T &       reference_type ;
    typedef T const&  reference_const_type ;
    typedef T &&      rval_reference_type ;
    typedef T *       pointer_type ;
    typedef T const*  pointer_const_type ;

    constexpr optional () noexcept ; 

    constexpr optional ( none_t ) noexcept ; 

    constexpr optional ( T const& v ) ; 

    constexpr optional ( T&& v ) ; 

    constexpr optional ( bool condition, T const& v ) ; 

    constexpr optional ( optional const& rhs ) ; 

    constexpr optional ( optional&& rhs ) noexcept(see below) ; 

    template<class U> constexpr explicit optional ( optional<U> const& rhs ) ; 

    template<class U> constexpr explicit optional ( optional<U>&& rhs ) ; 

    template<class... Args> constexpr explicit optional ( in_place_init_t, Args&&... args ) ; 

    template<class... Args> constexpr explicit optional ( in_place_init_if_t, bool condition, Args&&... args ) ; 

    template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; 

    template<class TypedInPlaceFactory> explicit optional ( TypedInPlaceFactory const& f ) ; 

    constexpr optional& operator = ( none_t ) noexcept ; 

    optional& operator = ( T const& v ) ; 

    optional& operator = ( T&& v ) ; 

    optional& operator = ( optional const& rhs ) ; 

    optional& operator = ( optional&& rhs ) noexcept(see below) ; 

    template<class U> optional& operator = ( optional<U> const& rhs ) ; 

    template<class U> optional& operator = ( optional<U>&& rhs ) ; 

    template<class... Args> void emplace ( Args&&... args ) ; 

    template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; 

    template<class TypedInPlaceFactory> optional& operator = ( TypedInPlaceFactory const& f ) ; 

    constexpr T const& get() const ; 
    constexpr T&       get() ; 

    constexpr T const* operator ->() const ; 
    constexpr T*       operator ->() ; 

    constexpr T const& operator *() const& ; 
    constexpr T&       operator *() & ; 
    constexpr T&&      operator *() && ; 

    constexpr T const& value() const& ; 
    constexpr T&       value() & ; 
    constexpr T&&      value() && ; 

    template<class U> constexpr T value_or( U && v ) const& ; 
    template<class U> constexpr T value_or( U && v ) && ; 

    template<class F> constexpr T value_or_eval( F f ) const& ; 
    template<class F> constexpr T value_or_eval( F f ) && ; 

    template<class F> constexpr auto map( F f ) const& -> see below; 
    template<class F> constexpr auto map( F f ) & -> see below; 
    template<class F> constexpr auto map( F f ) && -> see below; 

    template<class F> constexpr auto flat_map( F f ) const& -> see below; 
    template<class F> constexpr auto flat_map( F f ) & -> see below; 
    template<class F> constexpr auto flat_map( F f ) && -> see below; 

    constexpr operator optional<T&>() & noexcept; 
    constexpr operator optional<T const&>() const& noexcept; 

    T const* get_ptr() const ; 
    T*       get_ptr() ; 

    constexpr bool has_value() const noexcept ; 

    constexpr explicit operator bool() const noexcept ; 

    constexpr void reset() noexcept ; 

    // deprecated methods

    // (deprecated)
    void reset ( T const& ) ; 

    // (deprecated)
    constexpr bool is_initialized() const ; 

    // (deprecated)
    T const& get_value_or( T const& default ) const ; 
};

PrevUpHomeNext