Boost C++ Libraries

...one of the most highly regarded and expertly designed C++ library projects in the world. Herb Sutter and Andrei Alexandrescu, C++ Coding Standards

This is the documentation for an old version of Boost. Click here to view this page for the latest version.
PrevUpHomeNext

Synopsis

namespace boost {

template<class T>
class optional
{
    public :

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

    optional () ; R

    optional ( none_t ) ; R

    optional ( T const& v ) ; R

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

    optional ( optional const& rhs ) ; R

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

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

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

    optional& operator = ( none_t ) ; 

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

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

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

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

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

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

    // [new in 1.34]
    T const& get_value_or( T const& default ) const ; R 

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

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

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

    operator unspecified-bool-type() const ; R

    bool operator!() const ; R

    // deprecated methods

    // (deprecated)
    void reset() ; R

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

    // (deprecated)
    bool is_initialized() 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

// [new in 1.34]
template<class T> inline optional<T> make_optional ( T const& v ) ; R

// [new in 1.34]
template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; R

// [new in 1.34]
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