[/
    Boost.Optional

    Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal

    Distributed under the Boost Software License, Version 1.0.
    (See accompanying file LICENSE_1_0.txt or copy at
    http://www.boost.org/LICENSE_1_0.txt)
]


[#ref_header_optional_optional_hpp] [section:header_optional_optional Synopsis]

    ```// In Header: <`[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]'''<phrase role="comment">&gt;</phrase>'''``

    namespace boost {

    template <class T>
    class optional ; ``[link reference_operator_template __GO_TO__]``
    
    template <class T>
    class optional<T&> ; ``[link reference_operator_template_spec __GO_TO__]``
    
    template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_equal_optional_optional __GO_TO__]``

    template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_not_equal_optional_optional __GO_TO__]``

    template<class T> inline bool operator <  ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_less_optional_optional __GO_TO__]``

    template<class T> inline bool operator >  ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_optional_optional __GO_TO__]``

    template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]``

    template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]``
    
    template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]``

    template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]``

    template<class T> inline optional<T> make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]``

    template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]``

    template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_const_type def ) -> typename optional<T>::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]`` 
    
    template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_type def ) -> typename optional<T>::reference_type ; ``[link reference_free_get_value_or __GO_TO__]``

    template<class T> inline T const& get ( optional<T> const& opt ) ; ``[link reference_optional_get __GO_TO__]``

    template<class T> inline T& get ( optional<T> & opt ) ; ``[link reference_optional_get __GO_TO__]``

    template<class T> inline T const* get ( optional<T> const* opt ) ; ``[link reference_optional_get __GO_TO__]``

    template<class T> inline T* get ( optional<T>* opt ) ; ``[link reference_optional_get __GO_TO__]``

    template<class T> inline auto get_pointer ( optional<T> const& opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]``

    template<class T> inline auto get_pointer ( optional<T> & opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]``

    template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; ``[link reference_swap_optional_optional __GO_TO__]``
    
    template<class T> inline void swap( optional<T&>& x, optional<T&>& y ) ; ``[link reference_swap_optional_reference __GO_TO__]``

    } // namespace boost


[endsect]


[section:header_optional_optional_values Optional Values]

[#reference_operator_template]
    
    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 ;
        
        optional () noexcept ; ``[link reference_optional_constructor __GO_TO__]``

        optional ( none_t ) noexcept ; ``[link reference_optional_constructor_none_t __GO_TO__]``

        optional ( T const& v ) ; ``[link reference_optional_constructor_value __GO_TO__]``
        
        optional ( T&& v ) ; ``[link reference_optional_constructor_move_value __GO_TO__]``

        // [new in 1.34]
        optional ( bool condition, T const& v ) ; ``[link reference_optional_constructor_bool_value __GO_TO__]`` 

        optional ( optional const& rhs ) ; ``[link reference_optional_constructor_optional __GO_TO__]``
        
        optional ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_move_constructor_optional __GO_TO__]``

        template<class U> explicit optional ( optional<U> const& rhs ) ; ``[link reference_optional_constructor_other_optional __GO_TO__]``
        
        template<class U> explicit optional ( optional<U>&& rhs ) ; ``[link reference_optional_move_constructor_other_optional __GO_TO__]``

        template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; ``[link reference_optional_constructor_factory __GO_TO__]``

        template<class TypedInPlaceFactory> explicit optional ( TypedInPlaceFactory const& f ) ; ``[link reference_optional_constructor_factory __GO_TO__]``

        optional& operator = ( none_t ) noexcept ; ``[link reference_optional_operator_equal_none_t __GO_TO__]``

        optional& operator = ( T const& v ) ; ``[link reference_optional_operator_equal_value __GO_TO__]``
        
        optional& operator = ( T&& v ) ; ``[link reference_optional_operator_move_equal_value __GO_TO__]``

        optional& operator = ( optional const& rhs ) ; ``[link reference_optional_operator_equal_optional __GO_TO__]``
        
        optional& operator = ( optional&& rhs ) noexcept(``['see below]``) ; ``[link reference_optional_operator_move_equal_optional __GO_TO__]``

        template<class U> optional& operator = ( optional<U> const& rhs ) ; ``[link reference_optional_operator_equal_other_optional __GO_TO__]``
        
        template<class U> optional& operator = ( optional<U>&& rhs ) ; ``[link reference_optional_operator_move_equal_other_optional __GO_TO__]``
        
        template<class... Args> void emplace ( Args...&& args ) ; ``[link reference_optional_emplace __GO_TO__]``

        template<class InPlaceFactory> optional& operator = ( InPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``

        template<class TypedInPlaceFactory> optional& operator = ( TypedInPlaceFactory const& f ) ; ``[link reference_optional_operator_equal_factory __GO_TO__]``

        T const& get() const ; ``[link reference_optional_get __GO_TO__]``
        T&       get() ; ``[link reference_optional_get __GO_TO__]``

        T const* operator ->() const ; ``[link reference_optional_operator_arrow __GO_TO__]``
        T*       operator ->() ; ``[link reference_optional_operator_arrow __GO_TO__]``

        T const& operator *() const& ; ``[link reference_optional_operator_asterisk __GO_TO__]``
        T&       operator *() & ; ``[link reference_optional_operator_asterisk __GO_TO__]``
        T&&      operator *() && ; ``[link reference_optional_operator_asterisk_move __GO_TO__]``
        
        T const& value() const& ; ``[link reference_optional_value __GO_TO__]``
        T&       value() & ; ``[link reference_optional_value __GO_TO__]``
        T&&      value() && ; ``[link reference_optional_value_move __GO_TO__]``
        
        template<class U> T value_or( U && v ) const& ; ``[link reference_optional_value_or __GO_TO__]``
        template<class U> T value_or( U && v ) && ; ``[link reference_optional_value_or_move __GO_TO__]``
        
        template<class F> T value_or_eval( F f ) const& ; ``[link reference_optional_value_or_call __GO_TO__]``
        template<class F> T value_or_eval( F f ) && ; ``[link reference_optional_value_or_call_move __GO_TO__]``

        T const* get_ptr() const ; ``[link reference_optional_get_ptr __GO_TO__]``
        T*       get_ptr() ; ``[link reference_optional_get_ptr __GO_TO__]``

        explicit operator bool() const noexcept ; ``[link reference_optional_operator_bool __GO_TO__]``

        bool operator!() const noexcept ; ``[link reference_optional_operator_not __GO_TO__]``

        // deprecated methods

        // (deprecated)
        void reset() noexcept ; ``[link reference_optional_reset __GO_TO__]``

        // (deprecated)
        void reset ( T const& ) ; ``[link reference_optional_reset_value __GO_TO__]``

        // (deprecated)
        bool is_initialized() const ; ``[link reference_optional_is_initialized __GO_TO__]``

        // (deprecated)
        T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]`` 
    };


[endsect]


[section:header_optional_optional_refs Optional References]

[#reference_operator_template_spec]
    template <class T>
    class optional<T&> // specilization for lvalue references
    {
    public :

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

        optional () noexcept ; ``[link reference_optional_ref_default_ctor __GO_TO__]``

        optional ( none_t ) noexcept ; ``[link reference_optional_ref_default_ctor __GO_TO__]``

        template<class R> optional(R&& r) noexcept ;  ``[link reference_optional_ref_value_ctor __GO_TO__]``
        
        template <class R> optional(bool cond, R&& r) noexcept ; ``[link reference_optional_ref_cond_value_ctor __GO_TO__]``
        
        optional ( optional const& rhs ) noexcept ; ``[link reference_optional_ref_copy_ctor __GO_TO__]``

        template<class U> explicit optional ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_ctor_from_opt_U __GO_TO__]``

        optional& operator = ( none_t ) noexcept ; ``[link reference_optional_ref_assign_none_t __GO_TO__]``


        optional& operator = ( optional const& rhs ) noexcept; ``[link reference_optional_ref_copy_assign __GO_TO__]``

        template<class U> optional& operator = ( optional<U&> const& rhs ) noexcept ; ``[link reference_optional_ref_assign_optional_U __GO_TO__]``
          
        template<class R> optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]``      
        
        template<class R> void emplace ( R&& r ) noexcept ; ``[link reference_optional_ref_emplace_R __GO_TO__]``

        T& get() const ; ``[link reference_optional_ref_get __GO_TO__]``
        T& operator *() const ; ``[link reference_optional_ref_get __GO_TO__]``

        T* operator ->() const ; ``[link reference_optional_ref_arrow __GO_TO__]``

        T& value() const& ; ``[link reference_optional_ref_value __GO_TO__]``
        
        template<class R> T& value_or( R && r ) const noexcept ; ``[link reference_optional_ref_value_or __GO_TO__]``
        
        template<class F> T& value_or_eval( F f ) const ; ``[link reference_optional_ref_value_or_eval __GO_TO__]``

        T* get_ptr() const noexcept ; ``[link reference_optional_ref_get_ptr __GO_TO__]``

        explicit operator bool() const noexcept ; ``[link reference_optional_ref_operator_bool __GO_TO__]``

        bool operator!() const noexcept ; ``[link reference_optional_ref_operator_not __GO_TO__]``

        // deprecated methods

        // (deprecated)
        void reset() noexcept ; ``[link reference_optional_ref_reset __GO_TO__]``

        // (deprecated)
        template<class R> void reset ( R && r ) noexcept ; ``[link reference_optional_ref_reset_value __GO_TO__]``

        // (deprecated)
        bool is_initialized() const noexcept ; ``[link reference_optional_ref_is_initialized __GO_TO__]``

        // (deprecated)
        template<class R> T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]`` 
        
    private:
        T* ref; // exposition only
    };
[endsect]
