Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Synopsis

// In Header: <boost/optional/optional.hpp>

namespace boost {

template<class T>
class optional
{
    public :

    // (If T is of reference type, the parameters and results by reference are by value)

    optional () noexcept ; R

    optional ( none_t ) noexcept ; R

    optional ( T const& v ) ; R

    optional ( T&& v ) ; R

    // [new in 1.34]
    optional ( bool condition, T const& v ) ; R

    optional ( optional const& rhs ) ; R

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

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

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

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

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

    optional& operator = ( none_t ) noexcept ; R

    optional& operator = ( T const& v ) ; R

    optional& operator = ( T&& v ) ; R

    optional& operator = ( optional const& rhs ) ; R

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

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

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

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

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

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

    T const& get() const ; R
    T&       get() ; R

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

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

    T const& value() const& ; R
    T&       value() & ; R
    T&&      value() && ; R

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

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

    explicit operator bool() const ; R

    bool operator!() const noexcept ; R

    // deprecated methods

    // (deprecated)
    void reset() noexcept ; R

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

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

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

template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; R

template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; R

template<class T> inline bool operator <  ( optional<T> const& x, optional<T> const& y ) ; R

template<class T> inline bool operator >  ( optional<T> const& x, optional<T> const& y ) ; R

template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; R

template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; R

template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ; R

template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ; R

template<class T> inline optional<T> make_optional ( T const& v ) ; R

template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; R

template<class T> inline T const& get_optional_value_or ( optional<T> const& opt, T const& default ) ; R

template<class T> inline T const& get ( optional<T> const& opt ) ; R

template<class T> inline T& get ( optional<T> & opt ) ; R

template<class T> inline T const* get ( optional<T> const* opt ) ; R

template<class T> inline T* get ( optional<T>* opt ) ; R

template<class T> inline T const* get_pointer ( optional<T> const& opt ) ; R

template<class T> inline T* get_pointer ( optional<T> & opt ) ; R

template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; R

} // namespace boost

PrevUpHomeNext