diff --git a/doc/27_ref_optional_synopsis.qbk b/doc/27_ref_optional_synopsis.qbk index 042dd3d..6a4f853 100644 --- a/doc/27_ref_optional_synopsis.qbk +++ b/doc/27_ref_optional_synopsis.qbk @@ -9,21 +9,79 @@ ] -[#ref_header_optional_optional_hpp][section:header_optional_optional Synopsis] +[#ref_header_optional_optional_hpp] [section:header_optional_optional Synopsis] ```// In Header: <`[@boost:/boost/optional/optional.hpp boost/optional/optional.hpp]'''>'''`` namespace boost { + template + class optional ; ``[link reference_operator_template __GO_TO__]`` + + template + class optional ; ``[link reference_operator_template_spec __GO_TO__]`` + + template inline bool operator == ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_equal_optional_optional __GO_TO__]`` + + template inline bool operator != ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_not_equal_optional_optional __GO_TO__]`` + + template inline bool operator < ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_less_optional_optional __GO_TO__]`` + + template inline bool operator > ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_greater_optional_optional __GO_TO__]`` + + template inline bool operator <= ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]`` + + template inline bool operator >= ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]`` + + template inline bool operator == ( optional const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]`` + + template inline bool operator != ( optional const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]`` + + template inline optional make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]`` + + template inline optional make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]`` + + template inline auto get_optional_value_or ( optional const& opt, typename optional::reference_const_type def ) -> typename optional::reference_const_type; ``[link reference_free_get_value_or __GO_TO__]`` + + template inline auto get_optional_value_or ( optional const& opt, typename optional::reference_type def ) -> typename optional::reference_type ; ``[link reference_free_get_value_or __GO_TO__]`` + + template inline T const& get ( optional const& opt ) ; ``[link reference_optional_get __GO_TO__]`` + + template inline T& get ( optional & opt ) ; ``[link reference_optional_get __GO_TO__]`` + + template inline T const* get ( optional const* opt ) ; ``[link reference_optional_get __GO_TO__]`` + + template inline T* get ( optional* opt ) ; ``[link reference_optional_get __GO_TO__]`` + + template inline auto get_pointer ( optional const& opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]`` + + template inline auto get_pointer ( optional & opt ) -> ``['see below]``; ``[link reference_free_get_pointer __GO_TO__]`` + + template inline void swap( optional& x, optional& y ) ; ``[link reference_swap_optional_optional __GO_TO__]`` + + template inline void swap( optional& x, optional& y ) ; ``[link reference_swap_optional_reference __GO_TO__]`` + + } // namespace boost + + +[endsect] + + +[section:header_optional_optional_values Optional Values] + +[#reference_operator_template] + template class optional { public : - typedef T value_type; + typedef T value_type ; + typedef T & reference_type ; + typedef T const& reference_const_type ; + typedef T * pointer_type ; + typedef T const* pointer_const_type ; - // (If T is of reference type, the parameters and results by reference are by value) - optional () noexcept ; ``[link reference_optional_constructor __GO_TO__]`` optional ( none_t ) noexcept ; ``[link reference_optional_constructor_none_t __GO_TO__]`` @@ -109,43 +167,79 @@ T const& get_value_or( T const& default ) const ; ``[link reference_optional_get_value_or_value __GO_TO__]`` }; - template inline bool operator == ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_equal_optional_optional __GO_TO__]`` - - template inline bool operator != ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_not_equal_optional_optional __GO_TO__]`` - - template inline bool operator < ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_less_optional_optional __GO_TO__]`` - - template inline bool operator > ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_greater_optional_optional __GO_TO__]`` - - template inline bool operator <= ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_less_or_equal_optional_optional __GO_TO__]`` - - template inline bool operator >= ( optional const& x, optional const& y ) ; ``[link reference_operator_compare_greater_or_equal_optional_optional __GO_TO__]`` - - template inline bool operator == ( optional const& x, none_t ) noexcept ; ``[link reference_operator_compare_equal_optional_none __GO_TO__]`` - - template inline bool operator != ( optional const& x, none_t ) noexcept ; ``[link reference_operator_compare_not_equal_optional_none __GO_TO__]`` - - template inline optional make_optional ( T const& v ) ; ``[link reference_make_optional_value __GO_TO__]`` - - template inline optional make_optional ( bool condition, T const& v ) ; ``[link reference_make_optional_bool_value __GO_TO__]`` - - template inline T const& get_optional_value_or ( optional const& opt, T const& default ) ; ``[link reference_optional_get_value_or_value __GO_TO__]`` - - template inline T const& get ( optional const& opt ) ; ``[link reference_optional_get __GO_TO__]`` - - template inline T& get ( optional & opt ) ; ``[link reference_optional_get __GO_TO__]`` - - template inline T const* get ( optional const* opt ) ; ``[link reference_optional_get __GO_TO__]`` - - template inline T* get ( optional* opt ) ; ``[link reference_optional_get __GO_TO__]`` - - template inline T const* get_pointer ( optional const& opt ) ; ``[link reference_optional_get_ptr __GO_TO__]`` - - template inline T* get_pointer ( optional & opt ) ; ``[link reference_optional_get_ptr __GO_TO__]`` - - template inline void swap( optional& x, optional& y ) ; ``[link reference_swap_optional_optional __GO_TO__]`` - - } // namespace boost - [endsect] + + +[section:header_optional_optional_refs Optional References] + +[#reference_operator_template_spec] + template + class optional // specilization for lvalue references + { + public : + + typedef T& value_type; + typedef T& reference_type; + typedef T& reference_const_type; // no const propagation + 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 optional(R&& r) noexcept ; ``[link reference_optional_ref_value_ctor __GO_TO__]`` + + template 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 explicit optional ( optional 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 optional& operator = ( optional const& rhs ) noexcept ; ``[link reference_optional_ref_assign_optional_U __GO_TO__]`` + + template optional& operator = (R&& r) noexcept ; ``[link reference_optional_ref_assign_R __GO_TO__]`` + + template 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 T& value_or( R && r ) const noexcept ; ``[link reference_optional_ref_value_or __GO_TO__]`` + + template 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 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 T& get_value_or( R && r ) constnoexcept; ``[link reference_optional_ref_get_value_or_value __GO_TO__]`` + + private: + T* ref; // exposition only + }; +[endsect] diff --git a/doc/28_ref_optional_semantics.qbk b/doc/28_ref_optional_semantics.qbk index 791eb99..ca62937 100644 --- a/doc/28_ref_optional_semantics.qbk +++ b/doc/28_ref_optional_semantics.qbk @@ -9,18 +9,7 @@ ] -[section Detailed Semantics] - -Because `T` might be of reference type, in the sequel, those entries whose -semantic depends on `T` being of reference type or not will be distinguished -using the following convention: - -* If the entry reads: `optional`, the description -corresponds only to the case where `T` is not of reference type. -* If the entry reads: `optional`, the description corresponds only to -the case where `T` is of reference type. -* If the entry reads: `optional`, the description is the same for both -cases. +[section Detailed Semantics - Optional Values] [note The following section contains various `assert()` which are used only to show @@ -29,9 +18,6 @@ support each particular expression but that if the expression is supported, the implied condition holds. ] -__SPACE__ - -[heading optional class member functions] __SPACE__ @@ -70,7 +56,7 @@ __SPACE__ [#reference_optional_constructor_value] -[: `optional::optional( T const& v )`] +[: `optional::optional( T const& v )`] * [*Requires:] `is_copy_constructible::value` is `true`. * [*Effect:] Directly-Constructs an `optional`. @@ -87,29 +73,12 @@ optional opt(v); assert ( *opt == v ) ; `` -__SPACE__ - -[: `optional::optional( T& ref )`] - -* [*Effect:] Directly-Constructs an `optional`. -* [*Postconditions:] `*this` is [_initialized] and its value is an instance -of an internal type wrapping the reference `ref`. -* [*Throws:] Nothing. -* [*Example:] -`` -T v; -T& vref = v ; -optional opt(vref); -assert ( *opt == v ) ; -++ v ; // mutate referee -assert (*opt == v); -`` __SPACE__ [#reference_optional_constructor_move_value] -[: `optional::optional( T&& v )`] +[: `optional::optional( T&& v )`] * [*Requires:] `is_move_constructible::value` is `true`. * [*Effect:] Directly-Move-Constructs an `optional`. @@ -125,35 +94,27 @@ optional opt(std::move(v1)); assert ( *opt == v2 ) ; `` -__SPACE__ - -[: `optional::optional( T&& ref ) = delete`] - -* [*Notes:] This constructor is deleted - __SPACE__ [#reference_optional_constructor_bool_value] -[: `optional::optional( bool condition, T const& v ) ;` ] -[: `optional ::optional( bool condition, T& v ) ;` ] +[: `optional::optional( bool condition, T const& v ) ;` ] * If condition is true, same as: -[: `optional::optional( T const& v )`] -[: `optional ::optional( T& v )`] +[: `optional::optional( T const& v )`] * otherwise, same as: -[: `optional::optional()`] -[: `optional ::optional()`] +[: `optional::optional()`] + __SPACE__ [#reference_optional_constructor_optional] -[: `optional::optional( optional const& rhs );`] +[: `optional::optional( optional const& rhs );`] * [*Requires:] `is_copy_constructible::value` is `true`. * [*Effect:] Copy-Constructs an `optional`. @@ -178,43 +139,12 @@ optional init2 ( init ) ; assert ( init2 == init ) ; `` -__SPACE__ - -[: `optional::optional( optional const& rhs );`] - -* [*Effect:] Copy-Constructs an `optional`. -* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its -value is another reference to the same object referenced by `*rhs`; else -`*this` is uninitialized. -* [*Throws:] Nothing. -* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will refer to the -same object (they alias). -* [*Example:] -`` -optional uninit ; -assert (!uninit); - -optional uinit2 ( uninit ) ; -assert ( uninit2 == uninit ); - -T v = 2 ; T& ref = v ; -optional init(ref); -assert ( *init == v ) ; - -optional init2 ( init ) ; -assert ( *init2 == v ) ; - -v = 3 ; - -assert ( *init == 3 ) ; -assert ( *init2 == 3 ) ; -`` __SPACE__ [#reference_optional_move_constructor_optional] -[: `optional::optional( optional&& rhs ) noexcept(`['see below]`);`] +[: `optional::optional( optional&& rhs ) noexcept(`['see below]`);`] * [*Requires:] `is_move_constructible::value` is `true`. * [*Effect:] Move-constructs an `optional`. @@ -243,43 +173,12 @@ assert ( init2 ); assert ( **init2 == T(2) ) ; `` -__SPACE__ - -[: `optional::optional( optional && rhs );`] - -* [*Effect:] Move-Constructs an `optional`. -* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its -value is another reference to the same object referenced by `*rhs`; else -`*this` is uninitialized. -* [*Throws:] Nothing. -* [*Notes:] If `rhs` is initialized, both `*this` and `*rhs` will refer to the -same object (they alias). -* [*Example:] -`` -optional&> uninit ; -assert (!uninit); - -optional&> uinit2 ( std::move(uninit) ) ; -assert ( uninit2 == uninit ); - -std::unique_ptr v(new T(2)) ; -optional&> init(v); -assert ( *init == v ) ; - -optional&> init2 ( std::move(init) ) ; -assert ( *init2 == v ) ; - -*v = 3 ; - -assert ( **init == 3 ) ; -assert ( **init2 == 3 ) ; -`` __SPACE__ [#reference_optional_constructor_other_optional] -[: `template explicit optional::optional( optional const& rhs );`] +[: `template explicit optional::optional( optional const& rhs );`] * [*Effect:] Copy-Constructs an `optional`. * [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its @@ -303,7 +202,7 @@ __SPACE__ [#reference_optional_move_constructor_other_optional] -[: `template explicit optional::optional( optional&& rhs );`] +[: `template explicit optional::optional( optional&& rhs );`] * [*Effect:] Move-constructs an `optional`. * [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its @@ -327,8 +226,8 @@ __SPACE__ [#reference_optional_constructor_factory] -[: `template explicit optional::optional( InPlaceFactory const& f );`] -[: `template explicit optional::optional( TypedInPlaceFactory const& f );`] +[: `template explicit optional::optional( InPlaceFactory const& f );`] +[: `template explicit optional::optional( TypedInPlaceFactory const& f );`] * [*Effect:] Constructs an `optional` with a value of `T` obtained from the factory. @@ -365,7 +264,7 @@ __SPACE__ [#reference_optional_operator_equal_value] -[: `optional& optional::operator= ( T const& rhs ) ;`] +[: `optional& optional::operator= ( T const& rhs ) ;`] * [*Effect:] Assigns the value `rhs` to an `optional`. * [*Postconditions: ] `*this` is initialized and its value is a ['copy] of `rhs`. @@ -390,40 +289,12 @@ opt = y ; assert ( *opt == y ) ; `` -__SPACE__ - -[: `optional& optional::operator= ( T& rhs ) ;`] - -* [*Effect:] (Re)binds the wrapped reference. -* [*Postconditions: ] `*this` is initialized and it references the same -object referenced by `rhs`. -* [*Notes:] If `*this` was initialized, it is ['rebound] to the new object. -See [link boost_optional.tutorial.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior. -* [*Example:] -`` -int a = 1 ; -int b = 2 ; -T& ra = a ; -T& rb = b ; -optional def ; -optional opt(ra) ; - -def = rb ; // binds 'def' to 'b' through 'rb' -assert ( *def == b ) ; -*def = a ; // changes the value of 'b' to a copy of the value of 'a' -assert ( b == a ) ; -int c = 3; -int& rc = c ; -opt = rc ; // REBINDS to 'c' through 'rc' -c = 4 ; -assert ( *opt == 4 ) ; -`` __SPACE__ [#reference_optional_operator_move_equal_value] -[: `optional& optional::operator= ( T&& rhs ) ;`] +[: `optional& optional::operator= ( T&& rhs ) ;`] * [*Effect:] Moves the value `rhs` to an `optional`. * [*Postconditions: ] `*this` is initialized and its value is moved from `rhs`. @@ -448,18 +319,12 @@ opt = std::move(y2) ; assert ( *opt == yR ) ; `` -__SPACE__ - -[: `optional& optional::operator= ( T&& rhs ) = delete;`] - -* [*Notes:] This assignment operator is deleted. - __SPACE__ [#reference_optional_operator_equal_optional] -[: `optional& optional::operator= ( optional const& rhs ) ;`] +[: `optional& optional::operator= ( optional const& rhs ) ;`] * [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`. * [*Effects:] @@ -485,43 +350,12 @@ assert ( !def ) ; // previous value (copy of 'v') destroyed from within 'opt'. `` -__SPACE__ - -[: `optional & optional::operator= ( optional const& rhs ) ;`] - -* [*Effect:] (Re)binds thee wrapped reference. -* [*Postconditions:] If `*rhs` is initialized, `*this` is initialized and it -references the same object referenced by `*rhs`; otherwise, `*this` is -uninitialized (and references no object). -* [*Notes:] If `*this` was initialized and so is `*rhs`, `*this` is ['rebound] to -the new object. See [link boost_optional.tutorial.rebinding_semantics_for_assignment_of_optional_references here] for details on this behavior. -* [*Example:] -`` -int a = 1 ; -int b = 2 ; -T& ra = a ; -T& rb = b ; -optional def ; -optional ora(ra) ; -optional orb(rb) ; - -def = orb ; // binds 'def' to 'b' through 'rb' wrapped within 'orb' -assert ( *def == b ) ; -*def = ora ; // changes the value of 'b' to a copy of the value of 'a' -assert ( b == a ) ; -int c = 3; -int& rc = c ; -optional orc(rc) ; -ora = orc ; // REBINDS ora to 'c' through 'rc' -c = 4 ; -assert ( *ora == 4 ) ; -`` __SPACE__ [#reference_optional_operator_move_equal_optional] -[: `optional& optional::operator= ( optional&& rhs ) noexcept(`['see below]`);`] +[: `optional& optional::operator= ( optional&& rhs ) noexcept(`['see below]`);`] * [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`. * [*Effects:] @@ -548,18 +382,13 @@ assert ( opt ) ; assert ( *opt == T(2) ) ; `` -__SPACE__ - -[: `optional & optional::operator= ( optional&& rhs ) ;`] - -* [*Effect:] Same as `optional::operator= ( optional const& rhs )`. __SPACE__ [#reference_optional_operator_equal_other_optional] -[: `template optional& optional::operator= ( optional const& rhs ) ;`] +[: `template optional& optional::operator= ( optional const& rhs ) ;`] * [*Effect:] [table @@ -587,7 +416,7 @@ __SPACE__ [#reference_optional_operator_move_equal_other_optional] -[: `template optional& optional::operator= ( optional&& rhs ) ;`] +[: `template optional& optional::operator= ( optional&& rhs ) ;`] * [*Effect:] [table @@ -617,7 +446,7 @@ __SPACE__ [#reference_optional_emplace] -[: `template void optional::emplace( Args...&& args );`] +[: `template void optional::emplace( Args...&& args );`] * [*Requires:] The compiler supports rvalue references and variadic templates. * [*Effect:] If `*this` is initialized calls `*this = none`. @@ -642,8 +471,8 @@ __SPACE__ [#reference_optional_operator_equal_factory] -[: `template optional& optional::operator=( InPlaceFactory const& f );`] -[: `template optional& optional::operator=( TypedInPlaceFactory const& f );`] +[: `template optional& optional::operator=( InPlaceFactory const& f );`] +[: `template optional& optional::operator=( TypedInPlaceFactory const& f );`] * [*Effect:] Assigns an `optional` with a value of `T` obtained from the factory. @@ -659,7 +488,7 @@ __SPACE__ [#reference_optional_reset_value] -[: `void optional::reset( T const& v ) ;`] +[: `void optional::reset( T const& v ) ;`] * [*Deprecated:] same as `operator= ( T const& v) ;` __SPACE__ @@ -673,36 +502,24 @@ __SPACE__ [#reference_optional_get] -[: `T const& optional::get() const ;`] -[: `T& optional::get() ;`] +[: `T const& optional::get() const ;`] +[: `T& optional::get() ;`] -[: `inline T const& get ( optional const& ) ;`] -[: `inline T& get ( optional &) ;`] +[: `inline T const& get ( optional const& ) ;`] +[: `inline T& get ( optional &) ;`] * [*Requires:] `*this` is initialized * [*Returns:] A reference to the contained value * [*Throws:] Nothing. * [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. -__SPACE__ - -[: `T const& optional::get() const ;`] -[: `T& optional::get() ;`] - -[: `inline T const& get ( optional const& ) ;`] -[: `inline T& get ( optional &) ;`] - -* [*Requires: ] `*this` is initialized -* [*Returns:] [_The] reference contained. -* [*Throws:] Nothing. -* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. __SPACE__ [#reference_optional_operator_asterisk] -[: `T const& optional::operator*() const& ;`] -[: `T& optional::operator*() &;`] +[: `T const& optional::operator*() const& ;`] +[: `T& optional::operator*() &;`] * [*Requires:] `*this` is initialized * [*Returns:] A reference to the contained value @@ -723,32 +540,12 @@ __SPACE__ [#reference_optional_operator_asterisk_move] -[: `T&& optional::operator*() &&;`] +[: `T&& optional::operator*() &&;`] * [*Requires:] `*this` contains a value. * [*Effects:] Equivalent to `return std::move(*val);`. * [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On compilers that do not support ref-qualifiers on member functions this overload is not present. -__SPACE__ - -[: `T & optional::operator*() const& ;`] -[: `T & optional::operator*() & ;`] -[: `T & optional::operator*() && ;`] - -* [*Requires: ] `*this` is initialized -* [*Returns:] [_The] reference contained. -* [*Throws:] Nothing. -* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On compilers that do not support ref-qualifiers on member functions these three overloads are replaced with the classical two: a `const` and non-`const` member functions. -* [*Example:] -`` -T v ; -T& vref = v ; -optional opt ( vref ); -T const& vref2 = *opt; -assert ( vref2 == v ) ; -++ v ; -assert ( *opt == v ) ; -`` __SPACE__ @@ -845,11 +642,8 @@ __SPACE__ [#reference_optional_get_value_or_value] -[: `T const& optional::get_value_or( T const& default) const ;`] -[: `T& optional::get_value_or( T& default ) ;`] - -[: `inline T const& get_optional_value_or ( optional const& o, T const& default ) ;`] -[: `inline T& get_optional_value_or ( optional& o, T& default ) ;`] +[: `T const& optional::get_value_or( T const& default) const ;`] +[: `T& optional::get_value_or( T& default ) ;`] * [*Deprecated:] Use `value_or()` instead. * [*Returns:] A reference to the contained value, if any, or `default`. @@ -862,7 +656,7 @@ T const& y = def.get_value_or(z); assert ( y == z ) ; optional opt ( v ); -T const& u = get_optional_value_or(opt,z); +T const& u = opt.get_value_or(z); assert ( u == v ) ; assert ( u != z ) ; `` @@ -872,11 +666,8 @@ __SPACE__ [#reference_optional_get_ptr] -[: `T const* optional::get_ptr() const ;`] -[: `T* optional::get_ptr() ;`] - -[: `inline T const* get_pointer ( optional const& ) ;`] -[: `inline T* get_pointer ( optional &) ;`] +[: `T const* optional::get_ptr() const ;`] +[: `T* optional::get_ptr() ;`] * [*Returns:] If `*this` is initialized, a pointer to the contained value; else `0` (['null]). @@ -898,8 +689,8 @@ __SPACE__ [#reference_optional_operator_arrow] -[: `T const* optional::operator ->() const ;`] -[: `T* optional::operator ->() ;`] +[: `T const* optional::operator ->() const ;`] +[: `T* optional::operator ->() ;`] * [*Requires: ] `*this` is initialized. * [*Returns:] A pointer to the contained value. @@ -957,15 +748,300 @@ __SPACE__ * [*Deprecated:] Same as `explicit operator bool () ;` + +[endsect] + +[section Detailed Semantics - Optional References] + __SPACE__ -[heading Free functions] +[#reference_optional_ref_default_ctor] + +[: `optional::optional() noexcept;`] +[: `optional::optional(none_t) noexcept;`] + +* [*Postconditions:] `bool(*this) == false`; `*this` refers to nothing. + + +__SPACE__ + +[#reference_optional_ref_value_ctor] + +[: `template optional::optional(R&& r) noexcept;`] +* [*Postconditions:] `bool(*this) == true`; `addressof(**this) == addressof(r)`. +* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This constructor does not participate in overload resolution if `decay` is an instance of `boost::optional`. +* [*Example:] +`` +T v; +T& vref = v ; +optional opt(vref); +assert ( *opt == v ) ; +++ v ; // mutate referee +assert (*opt == v); +`` + +__SPACE__ + +[#reference_optional_ref_cond_value_ctor] + +[: `template optional::optional(bool cond, R&& r) noexcept;`] +* [*Effects: ] Initializes `ref` with expression `cond ? addressof(r) : nullptr`. +* [*Postconditions:] `bool(*this) == cond`; If `bool(*this)`, `addressof(**this) == addressof(r)`. +* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This constructor does not participate in overload resolution if `decay` is an instance of `boost::optional`. + +__SPACE__ + +[#reference_optional_ref_copy_ctor] + +[: `optional::optional ( optional const& rhs ) noexcept ;`] + +* [*Effects: ] Initializes `ref` with expression `rhs.ref`. + +* [*Postconditions:] `bool(*this) == bool(rhs)`. + +* [*Example:] +`` +optional uninit ; +assert (!uninit); + +optional uinit2 ( uninit ) ; +assert ( uninit2 == uninit ); + +T v = 2 ; T& ref = v ; +optional init(ref); +assert ( *init == v ) ; + +optional init2 ( init ) ; +assert ( *init2 == v ) ; + +v = 3 ; + +assert ( *init == 3 ) ; +assert ( *init2 == 3 ) ; +`` + +__SPACE__ + +[#reference_optional_ref_ctor_from_opt_U] + +[: `template explicit optional::optional ( optional const& rhs ) noexcept ;`] + +* [*Requires:] `is_convertible::value` is `true`. + +* [*Effects: ] Initializes `ref` with expression `rhs.ref`. + +* [*Postconditions:] `bool(*this) == bool(rhs)`. + + +__SPACE__ + +[#reference_optional_ref_assign_none_t] + +[: `optional::operator= ( none_t ) noexcept ;`] + +* [*Effects: ] Assigns `ref` with expression `nullptr`. + +* [*returns:] `*this`. + +* [*Postconditions:] `bool(*this) == false`. + + + +[#reference_optional_ref_copy_assign] + +[: `optional& optional::operator= ( optional const& rhs ) noexcept ;`] + +* [*Effects: ] Assigns `ref` with expression `rhs.ref`. + +* [*returns:] `*this`. + +* [*Postconditions:] `bool(*this) == bool(rhs)`. + +* [*Notes:] This behaviour is called ['rebinding semantics]. See [link boost_optional.tutorial.rebinding_semantics_for_assignment_of_optional_references here] for details. + +* [*Example:] +`` +int a = 1 ; +int b = 2 ; +T& ra = a ; +T& rb = b ; +optional def ; +optional ora(ra) ; +optional orb(rb) ; + +def = orb ; // binds 'def' to 'b' through 'rb' wrapped within 'orb' +assert ( *def == b ) ; +*def = ora ; // changes the value of 'b' to a copy of the value of 'a' +assert ( b == a ) ; +int c = 3; +int& rc = c ; +optional orc(rc) ; +ora = orc ; // REBINDS ora to 'c' through 'rc' +c = 4 ; +assert ( *ora == 4 ) ; +`` + + +[#reference_optional_ref_assign_optional_U] + +[: `template optional& optional::operator= ( optional const& rhs ) noexcept ;`] + +* [*Requires:] `is_convertible::value` is `true`. + +* [*Effects: ] Assigns `ref` with expression `rhs.ref`. + +* [*returns:] `*this`. + +* [*Postconditions:] `bool(*this) == bool(rhs)`. + + +__SPACE__ + +[#reference_optional_ref_assign_R] + +[: `template optional& optional::operator= ( R&& r ) noexcept ;`] + +* [*Effects: ] Assigns `ref` with expression `r`. + +* [*returns:] `*this`. + +* [*Postconditions:] `bool(*this) == true`. + +* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This function does not participate in overload resolution if `decay` is an instance of `boost::optional`. + +* [*Example:] +`` +int a = 1 ; +int b = 2 ; +T& ra = a ; +T& rb = b ; +optional def ; +optional opt(ra) ; + +def = rb ; // binds 'def' to 'b' through 'rb' +assert ( *def == b ) ; +*def = a ; // changes the value of 'b' to a copy of the value of 'a' +assert ( b == a ) ; +int c = 3; +int& rc = c ; +opt = rc ; // REBINDS to 'c' through 'rc' +c = 4 ; +assert ( *opt == 4 ) ; +`` + +__SPACE__ + +[#reference_optional_ref_emplace_R] + +[: `void optional::emplace( R&& r ) noexcept ;`] +* [*Effects: ] Assigns `ref` with expression `r`. +* [*Postconditions:] `bool(*this) == true`. +* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. This function does not participate in overload resolution if `decay` is an instance of `boost::optional`. + +__SPACE__ + +[#reference_optional_ref_get] +[: `T& optional::get() const ;`] +[: `T& optional::operator *() const ;`] +* [*Requires:] `bool(*this) == true`. +* [*Effects: ] Returns `*ref`. +* [*Throws: ] Nothing. +* [*Example:] +`` +T v ; +T& vref = v ; +optional opt ( vref ); +T const& vref2 = *opt; +assert ( vref2 == v ) ; +++ v ; +assert ( *opt == v ) ; +`` + +__SPACE__ + +[#reference_optional_ref_arrow] +[: `T* optional::operator -> () const ;`] +* [*Requires:] `bool(*this) == true`. +* [*Effects: ] Returns `ref`. +* [*Throws: ] Nothing. + +__SPACE__ + +[#reference_optional_ref_value] +[: `T& optional::value() const ;`] +* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`. + +__SPACE__ + +[#reference_optional_ref_value_or] +[: `template T& optional::value_or( R&& r ) const noexcept;`] +* [*Effects:] Equivalent to `if (*this) return **this; else return r;`. +* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed. + +__SPACE__ + +[#reference_optional_ref_value_or_eval] +[: `template T& optional::value_or( F f ) const ;`] +* [*Effects:] Equivalent to `if (*this) return **this; else return f();`. +* [*Remarks:] Unless `decltype(f())` is an lvalue reference, the program is ill-formed. + +__SPACE__ + +[#reference_optional_ref_get_ptr] +[: `T* optional::get_ptr () const noexcept;`] +* [*Returns:] `ref`. + +__SPACE__ + +[#reference_optional_ref_operator_bool] +[: `optional::operator bool () const noexcept;`] +* [*Returns:] `bool(ref)`. + +__SPACE__ + +[#reference_optional_ref_operator_not] +[: `optional::operator ! () const noexcept;`] +* [*Returns:] `!bool(ref)`. + +__SPACE__ + +[#reference_optional_ref_reset] +[: `void optional::reset() noexcept;`] +* [*Effects:] Use `*this = none` instead. +* [*Remarks:] This function is depprecated. + +__SPACE__ + +[#reference_optional_ref_reset_value] +[: `template void optional::reset ( R&& r) noexcept;`] +* [*Effects:] Equivalent to `*this = std::forward(r)`. +* [*Remarks:] This function is depprecated. + +__SPACE__ + +[#reference_optional_ref_is_initialized] +[: `bool optional::is_initialized() const noexcept;`] +* [*Effects:] Equivalent to `return bool(*this)`. +* [*Remarks:] This function is depprecated. + +__SPACE__ + +[#reference_optional_ref_get_value_or_value] +[: `template T& optional::get_value_or( R&& r ) const noexcept;`] +* [*Effects:] Equivalent to `return value_or(std::forward(r);`. +* [*Remarks:] This function is depprecated. + +[endsect] + + +[section Detailed Semantics - Free Functions] + __SPACE__ [#reference_make_optional_value] -[: `optional make_optional( T const& v )`] +[: `optional make_optional( T const& v )`] * [*Returns: ] `optional(v)` for the ['deduced] type `T` of `v`. * [*Example:] @@ -979,9 +1055,9 @@ __SPACE__ [#reference_make_optional_bool_value] -[: `optional make_optional( bool condition, T const& v )`] +[: `optional make_optional( bool condition, T const& v )`] -* [*Returns: ] `optional(condition,v)` for the ['deduced] type `T` of `v`. +* [*Returns: ] `optional(condition, v)` for the ['deduced] type `T` of `v`. * [*Example:] `` optional calculate_foo() @@ -1108,6 +1184,25 @@ __SPACE__ * [*Returns: ] `!( x == y );` +__SPACE__ + + +[#reference_free_get_pointer] +[: `auto get_pointer ( optional& o ) -> typename optional::pointer_type ;`] +[: `auto get_pointer ( optional const& o ) -> typename optional::pointer_const_type ;`] +* [*Returns:] `o.get_ptr()`. +* [*Throws:] Nothing. + +__SPACE__ + + +[#reference_free_get_value_or] +[: `auto get_optional_value_or ( optional& o, typename optional::reference_type def ) -> typename optional::reference_type ;`] +[: `auto get_optional_value_or ( optional const& o, typename optional::reference_const_type def ) -> typename optional::reference_const_type ;`] +* [*Returns:] `o.get_value_or(def)`. +* [*Throws:] Nothing. +* [*Remarks:] This function is deprecated. + __SPACE__ [#reference_swap_optional_optional] @@ -1147,4 +1242,30 @@ assert ( *optX == y ); assert ( *optY == x ); `` -[endsect] +__SPACE__ + +[#reference_swap_optional_reference] +[: `void swap ( optional& x, optional& y ) noexcept ;`] + +* [*Postconditions:] `x` refers to what `y` refererred to before the swap (if anything). `y` refers to whatever `x` referred to before the swap. + +* [*Example:] +`` +T x(12); +T y(21); + +optional opt0; +optional optX (x); +optional optY (y); + +boost::swap(optX, optY); +assert (addressof(*optX) == addressof(y)); +assert (addressof(*optY) == addressof(x)); + +boost::swap(opt0, optX); +assert ( opt0 ); +assert ( !optX ); +assert (addressof(*opt0) == addressof(y)); +`` + +[endsect] \ No newline at end of file diff --git a/doc/html/boost_optional/reference/acknowledgements.html b/doc/html/boost_optional/reference/acknowledgements.html new file mode 100644 index 0000000..f5a719d --- /dev/null +++ b/doc/html/boost_optional/reference/acknowledgements.html @@ -0,0 +1,131 @@ + + + +Acknowledgements + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHome +
+
+ +
+ + Pre-formal + review +
+
    +
  • + Peter Dimov suggested the name 'optional', and was the first to point + out the need for aligned storage. +
  • +
  • + Douglas Gregor developed 'type_with_alignment', and later Eric Friedman + coded 'aligned_storage', which are the core of the optional class implementation. +
  • +
  • + Andrei Alexandrescu and Brian Parker also worked with aligned storage + techniques and their work influenced the current implementation. +
  • +
  • + Gennadiy Rozental made extensive and important comments which shaped + the design. +
  • +
  • + Vesa Karvonen and Douglas Gregor made quite useful comparisons between + optional, variant and any; and made other relevant comments. +
  • +
  • + Douglas Gregor and Peter Dimov commented on comparisons and evaluation + in boolean contexts. +
  • +
  • + Eric Friedman helped understand the issues involved with aligned storage, + move/copy operations and exception safety. +
  • +
  • + Many others have participated with useful comments: Aleksey Gurotov, + Kevlin Henney, David Abrahams, and others I can't recall. +
  • +
+
+ + Post-formal + review +
+
    +
  • + William Kempf carefully considered the originally proposed interface + and suggested the new interface which is currently used. He also started + and fueled the discussion about the analogy optional<>/smart pointer + and about relational operators. +
  • +
  • + Peter Dimov, Joel de Guzman, David Abrahams, Tanton Gibbs and Ian Hanson + focused on the relational semantics of optional (originally undefined); + concluding with the fact that the pointer-like interface doesn't make + it a pointer so it shall have deep relational operators. +
  • +
  • + Augustus Saunders also explored the different relational semantics between + optional<> and a pointer and developed the OptionalPointee concept + as an aid against potential conflicts on generic code. +
  • +
  • + Joel de Guzman noticed that optional<> can be seen as an API on + top of variant<T,nil_t>. +
  • +
  • + Dave Gomboc explained the meaning and usage of the Haskell analog to + optional<>: the Maybe type constructor (analogy originally pointed + out by David Sankel). +
  • +
  • + Other comments were posted by Vincent Finn, Anthony Williams, Ed Brey, + Rob Stewart, and others. +
  • +
  • + Joel de Guzman made the case for the support of references and helped + with the proper semantics. +
  • +
  • + Mat Marcus shown the virtues of a value-oriented interface, influencing + the current design, and contributed the idea of "none". +
  • +
  • + Vladimir Batov's design of Boost.Convert library motivated the development + of value accessors for optional: + functions value, value_or, value_or_eval. +
  • +
+
+ + + +
+
+
+PrevUpHome +
+ + diff --git a/doc/html/boost_optional/reference/dependencies_and_portability.html b/doc/html/boost_optional/reference/dependencies_and_portability.html new file mode 100644 index 0000000..5128861 --- /dev/null +++ b/doc/html/boost_optional/reference/dependencies_and_portability.html @@ -0,0 +1,84 @@ + + + +Dependencies and Portability + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ +

+ The implementation uses the following other Boost modules: +

+
    +
  1. + assert +
  2. +
  3. + config +
  4. +
  5. + core +
  6. +
  7. + detail +
  8. +
  9. + move +
  10. +
  11. + mpl +
  12. +
  13. + static_assert +
  14. +
  15. + throw_exception +
  16. +
  17. + type_traits +
  18. +
  19. + utility +
  20. +
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/dependencies_and_portability/optional_reference_binding.html b/doc/html/boost_optional/reference/dependencies_and_portability/optional_reference_binding.html new file mode 100644 index 0000000..16c1637 --- /dev/null +++ b/doc/html/boost_optional/reference/dependencies_and_portability/optional_reference_binding.html @@ -0,0 +1,100 @@ + + + +Optional Reference Binding + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ On compilers that do not conform to Standard C++ rules of reference binding, + operations on optional references might give adverse results: rather than + binding a reference to a designated object they may create an unexpected + temporary and bind to it. Compilers known to have these deficiencies include + GCC versions 4.2, 4.3, 4.4, 4.5; QCC 4.4.2; MSVC versions 8.0, 9.0, 10.0, + 11.0, 12.0. On these compilers prefer using direct-initialization and copy + assignment of optional references to copy-initialization and assignment + from T&: +

+
const int i = 0;
+optional<const int&> or1;
+optional<const int&> or2 = i;  // not portable
+or1 = i;                       // not portable
+
+optional<const int&> or3(i);   // portable
+or1 = optional<const int&>(i); // portable
+
+

+ In order to check if your compiler correctly implements reference binding + use this test program. +

+
#include <cassert>
+
+const int global_i = 0;
+
+struct TestingReferenceBinding
+{
+  TestingReferenceBinding(const int& ii)
+  {
+    assert(&ii == &global_i);
+  }
+
+  void operator=(const int& ii)
+  {
+    assert(&ii == &global_i);
+  }
+
+  void operator=(int&&) // remove this if your compiler doesn't have rvalue refs
+  {
+    assert(false);
+  }
+};
+
+int main()
+{
+  const int& iref = global_i;
+  assert(&iref == &global_i);
+
+  TestingReferenceBinding ttt = global_i;
+  ttt = global_i;
+
+  TestingReferenceBinding ttt2 = iref;
+  ttt2 = iref;
+}
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_hpp_.html b/doc/html/boost_optional/reference/header__boost_optional_hpp_.html index 7a8c7ca..52d67c3 100644 --- a/doc/html/boost_optional/reference/header__boost_optional_hpp_.html +++ b/doc/html/boost_optional/reference/header__boost_optional_hpp_.html @@ -6,7 +6,7 @@ - + @@ -20,7 +20,7 @@
-PrevUpHomeNext +PrevUpHomeNext

@@ -41,7 +41,7 @@
-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html index 041b651..b7d25f5 100644 --- a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics.html @@ -6,8 +6,8 @@ - - + + @@ -20,7 +20,7 @@

-PrevUpHomeNext +PrevUpHomeNext

@@ -2368,6 +2368,44 @@

+

+ space +

+

+ void swap + ( optional<T&>& x, optional<T&>& y + ) noexcept + ; +

+
    +
  • + Postconditions: x + refers to what y refererred + to before the swap (if anything). y + refers to whatever x + referred to before the swap. +
  • +
  • + Example: +
    T x(12);
    +T y(21);
    +
    +optional<T&> opt0;
    +optional<T&> optX (x);
    +optional<T&> optY (y);
    +
    +boost::swap(optX, optY);
    +assert (addressof(*optX) == addressof(y));
    +assert (addressof(*optY) == addressof(x));
    +
    +boost::swap(opt0, optX);
    +assert ( opt0 );
    +assert ( !optX );
    +assert (addressof(*opt0) == addressof(y));
    +
    + [endsect] +
  • +
@@ -2379,7 +2417,7 @@

-PrevUpHomeNext +PrevUpHomeNext
diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____free_functions.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____free_functions.html new file mode 100644 index 0000000..462f109 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____free_functions.html @@ -0,0 +1,447 @@ + + + +Detailed Semantics -- Free Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ space +

+

+ optional<T> make_optional( + T const& v ) +

+
    +
  • + Returns: optional<T>(v) for the deduced + type T of v. +
  • +
  • + Example: +
    template<class T> void foo ( optional<T> const& opt ) ;
    +
    +foo ( make_optional(1+1) ) ; // Creates an optional<int>
    +
    +
  • +
+

+ space +

+

+ optional<T (not a ref)> make_optional( bool condition, + T const& v ) +

+
    +
  • + Returns: optional<T>(condition,v) for the deduced + type T of v. +
  • +
  • + Example: +
    optional<double> calculate_foo()
    +{
    +  double val = compute_foo();
    +  return make_optional(is_not_nan_and_finite(val),val);
    +}
    +
    +optional<double> v = calculate_foo();
    +if ( !v )
    +  error("foo wasn't computed");
    +
    +
  • +
+

+ space +

+

+ bool operator + == ( + optional<T> const& x, optional<T> const& y ); +

+
    +
  • + Requires: T + shall meet requirements of EqualityComparable. +
  • +
  • + Returns: If both x + and y are initialized, + (*x + == *y). + If only x or y is initialized, false. + If both are uninitialized, true. +
  • +
  • + Notes: This definition guarantees + that optional<T> + not containing a value is compared unequal to any optional<T> containing any value, and equal + to any other optional<T> not containing a value. Pointers + have shallow relational operators while optional + has deep relational operators. Do not use operator== directly in generic code which expect + to be given either an optional<T> or a pointer; use equal_pointees() + instead +
  • +
  • + Example: +
    optional<T> oN, oN_;
    +optional<T> o1(T(1)), o1_(T(1));
    +optional<T> o2(T(2));
    +
    +assert ( oN == oN );  // Identity implies equality
    +assert ( o1 == o1 );  //
    +
    +assert ( oN == oN_ ); // Both uninitialized compare equal
    +
    +assert ( oN != o1 );  // Initialized unequal to initialized.
    +
    +assert ( o1 == o1_ ); // Both initialized compare as (*lhs == *rhs)
    +assert ( o1 != o2 );  //
    +
    +
  • +
+

+ space +

+

+ bool operator + < ( + optional<T> const& x, optional<T> const& y ); +

+
    +
  • + Requires: Expression *x < *y shall be well-formed and its result + shall be convertible to bool. +
  • +
  • + Returns: (!y) ? false : (!x) ? true : *x < + *y. +
  • +
  • + Notes: This definition guarantees + that optional<T> + not containing a value is ordered as less than any optional<T> containing any value, and equivalent + to any other optional<T> not containing a value. Pointers + have shallow relational operators while optional + has deep relational operators. Do not use operator< directly in generic code which + expect to be given either an optional<T> or a pointer; use less_pointees() + instead. T need not + be LessThanComparable. Only + single operator< + is required. Other relational operations are defined in terms of this + one. If T's operator< + satisfies the axioms of LessThanComparable (transitivity, + antisymmetry and irreflexivity), optinal<T> is LessThanComparable. +
  • +
  • + Example: +
    optional<T> oN, oN_;
    +optional<T> o0(T(0));
    +optional<T> o1(T(1));
    +
    +assert ( !(oN < oN) );  // Identity implies equivalence
    +assert ( !(o1 < o1) );
    +
    +assert ( !(oN < oN_) ); // Two uninitialized are equivalent
    +assert ( !(oN_ < oN) );
    +
    +assert ( oN < o0 );     // Uninitialized is less than initialized
    +assert ( !(o0 < oN) );
    +
    +assert ( o1 < o2 ) ;    // Two initialized compare as (*lhs < *rhs)
    +assert ( !(o2 < o1) ) ;
    +assert ( !(o2 < o2) ) ;
    +
    +
  • +
+

+ space +

+

+ bool operator + != ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: !( + x == + y ); +
+

+ space +

+

+ bool operator + > ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: ( + y < + x ); +
+

+ space +

+

+ bool operator + <= ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: !( + y < + x ); +
+

+ space +

+

+ bool operator + >= ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: !( + x < + y ); +
+

+ space +

+

+ bool operator + == ( + optional<T> const& x, none_t ) + noexcept; +

+

+ bool operator + == ( + none_t, + optional<T> const& x ) noexcept; +

+
+

+ space +

+

+ bool operator + != ( + optional<T> const& x, none_t ) + noexcept; +

+

+ bool operator + != ( + none_t, + optional<T> const& x ) noexcept; +

+
  • + Returns: !( + x == + y ); +
+

+ space +

+

+ void swap + ( optional<T>& x, optional<T>& y + ) ; +

+
    +
  • + Requires: Lvalues of type T shall be swappable and T shall be MoveConstructible. +
  • +
  • +

    + Effects: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + calls swap(*(*this), *rhs) +

    +
    +

    + initializes the contained value of *this as if direct-initializing + an object of type T + with the expression std::move(*rhs), followed by rhs.val->T::~T(), + *this + contains a value and rhs + does not contain a value +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + initializes the contained value of rhs + as if direct-initializing an object of type T with the expression + std::move(*(*this)), + followed by val->T::~T(), *this does not contain a value + and rhs contains + a value +

    +
    +

    + no effect +

    +
    +
  • +
  • + Postconditions: The states of x and y + interchanged. +
  • +
  • + Throws: If both are initialized, whatever + swap(T&,T&) + throws. If only one is initialized, whatever T::T ( T&& ) + throws. +
  • +
  • + Example: +
    T x(12);
    +T y(21);
    +optional<T> def0 ;
    +optional<T> def1 ;
    +optional<T> optX(x);
    +optional<T> optY(y);
    +
    +boost::swap(def0,def1); // no-op
    +
    +boost::swap(def0,optX);
    +assert ( *def0 == x );
    +assert ( !optX );
    +
    +boost::swap(def0,optX); // Get back to original values
    +
    +boost::swap(optX,optY);
    +assert ( *optX == y );
    +assert ( *optY == x );
    +
    +
  • +
+

+ space +

+

+ void swap + ( optional<T&>& x, optional<T&>& y + ) noexcept + ; +

+
    +
  • + Postconditions: x + refers to what y refererred + to before the swap (if anything). y + refers to whatever x + referred to before the swap. +
  • +
  • + Example: +
    T x(12);
    +T y(21);
    +
    +optional<T&> opt0;
    +optional<T&> optX (x);
    +optional<T&> optY (y);
    +
    +boost::swap(optX, optY);
    +assert (addressof(*optX) == addressof(y));
    +assert (addressof(*optY) == addressof(x));
    +
    +boost::swap(opt0, optX);
    +assert ( opt0 );
    +assert ( !optX );
    +assert (addressof(*opt0) == addressof(y));
    +
    + [endsect] +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____optional_references.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____optional_references.html new file mode 100644 index 0000000..7eedfab --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____optional_references.html @@ -0,0 +1,57 @@ + + + +Detailed Semantics -- Optional References + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ space +

+

+ optional<&>::optional() + noexcept; +

+

+ optional<&>::optional(none_t) noexcept; +

+
  • + Postconditions: *this refers to nothing. +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____optional_values.html new file mode 100644 index 0000000..5fd6391 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics____optional_values.html @@ -0,0 +1,1983 @@ + + + +Detailed Semantics -- Optional Values + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + + + + +
[Note]Note

+ The following section contains various assert() which are used only to show the postconditions + as sample code. It is not implied that the type T + must support each particular expression but that if the expression is + supported, the implied condition holds. +

+

+ space +

+

+ optional<T>::optional() + noexcept; +

+
    +
  • + Effect: Default-Constructs an optional. +
  • +
  • + Postconditions: *this is uninitialized. +
  • +
  • + Notes: T's default constructor is not called. +
  • +
  • + Example: +
    optional<T> def ;
    +assert ( !def ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T>::optional( + none_t ) + noexcept; +

+
    +
  • + Effect: Constructs an optional uninitialized. +
  • +
  • + Postconditions: *this is uninitialized. +
  • +
  • + Notes: T's + default constructor is not called. + The expression boost::none + denotes an instance of boost::none_t + that can be used as the parameter. +
  • +
  • + Example: +
    #include <boost/none.hpp>
    +optional<T> n(none) ;
    +assert ( !n ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T (not a ref)>::optional( T const& v ) +

+
    +
  • + Requires: is_copy_constructible<T>::value + is true. +
  • +
  • + Effect: Directly-Constructs an optional. +
  • +
  • + Postconditions: *this is initialized + and its value is a copy of v. +
  • +
  • + Throws: Whatever T::T( T const& + ) throws. +
  • +
  • + Notes: T::T( T const& + ) is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T const& + ); in that case, this constructor + has no effect. +
  • +
  • + Example: +
    T v;
    +optional<T> opt(v);
    +assert ( *opt == v ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&>::optional( + T& + ref ) +

+
    +
  • + Effect: Directly-Constructs an optional. +
  • +
  • + Postconditions: *this is initialized + and its value is an instance of an internal type wrapping the reference + ref. +
  • +
  • + Throws: Nothing. +
  • +
  • + Example: +
    T v;
    +T& vref = v ;
    +optional<T&> opt(vref);
    +assert ( *opt == v ) ;
    +++ v ; // mutate referee
    +assert (*opt == v);
    +
    +
  • +
+

+ space +

+

+ optional<T (not a ref)>::optional( T&& v + ) +

+
    +
  • + Requires: is_move_constructible<T>::value + is true. +
  • +
  • + Effect: Directly-Move-Constructs an + optional. +
  • +
  • + Postconditions: *this is initialized + and its value is move-constructed from v. +
  • +
  • + Throws: Whatever T::T( T&& ) + throws. +
  • +
  • + Notes: T::T( T&& ) + is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T&& ); + in that case, the state of v + is determined by exception safety guarantees for T::T(T&&). +
  • +
  • + Example: +
    T v1, v2;
    +optional<T> opt(std::move(v1));
    +assert ( *opt == v2 ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&>::optional( + T&& + ref ) + = delete +

+
  • + Notes: This constructor is deleted +
+

+ space +

+

+ optional<T (not a ref)>::optional( bool condition, + T const& v ) ; +

+

+ optional<T&> + ::optional( bool condition, + T& + v ) + ; +

+
  • + If condition is true, same as: +
+

+ optional<T (not a ref)>::optional( T const& v ) +

+

+ optional<T&> + ::optional( T& v ) +

+
  • + otherwise, same as: +
+

+ optional<T (not a ref)>::optional() +

+

+ optional<T&> + ::optional() +

+

+ space +

+

+ optional<T (not a ref)>::optional( optional + const& + rhs ); +

+
    +
  • + Requires: is_copy_constructible<T>::value + is true. +
  • +
  • + Effect: Copy-Constructs an optional. +
  • +
  • + Postconditions: If rhs is initialized, + *this + is initialized and its value is a copy of the + value of rhs; else + *this + is uninitialized. +
  • +
  • + Throws: Whatever T::T( T const& + ) throws. +
  • +
  • + Notes: If rhs is initialized, T::T(T const& ) + is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T const& + ); in that case, this constructor + has no effect. +
  • +
  • + Example: +
    optional<T> uninit ;
    +assert (!uninit);
    +
    +optional<T> uinit2 ( uninit ) ;
    +assert ( uninit2 == uninit );
    +
    +optional<T> init( T(2) );
    +assert ( *init == T(2) ) ;
    +
    +optional<T> init2 ( init ) ;
    +assert ( init2 == init ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&>::optional( + optional const& rhs + ); +

+
    +
  • + Effect: Copy-Constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is another reference to the same object + referenced by *rhs; + else *this + is uninitialized. +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: If rhs + is initialized, both *this and *rhs will refer to the same object + (they alias). +
  • +
  • + Example: +
    optional<T&> uninit ;
    +assert (!uninit);
    +
    +optional<T&> uinit2 ( uninit ) ;
    +assert ( uninit2 == uninit );
    +
    +T v = 2 ; T& ref = v ;
    +optional<T> init(ref);
    +assert ( *init == v ) ;
    +
    +optional<T> init2 ( init ) ;
    +assert ( *init2 == v ) ;
    +
    +v = 3 ;
    +
    +assert ( *init  == 3 ) ;
    +assert ( *init2 == 3 ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T (not a ref)>::optional( optional&& rhs + ) noexcept(see below); +

+
    +
  • + Requires: is_move_constructible<T>::value + is true. +
  • +
  • + Effect: Move-constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is move constructed from rhs; else *this is uninitialized. +
  • +
  • + Throws: Whatever T::T( T&& ) + throws. +
  • +
  • + Remarks: The expression inside noexcept is equivalent to is_nothrow_move_constructible<T>::value. +
  • +
  • + Notes: If rhs + is initialized, T::T( T && + ) is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T&& ); + in that case, rhs remains + initialized and the value of *rhs is determined by exception safety + of T::T(T&&). +
  • +
  • + Example: +
    optional<std::unique_ptr<T>> uninit ;
    +assert (!uninit);
    +
    +optional<std::unique_ptr<T>> uinit2 ( std::move(uninit) ) ;
    +assert ( uninit2 == uninit );
    +
    +optional<std::unique_ptr<T>> init( std::uniqye_ptr<T>(new T(2)) );
    +assert ( **init == T(2) ) ;
    +
    +optional<std::unique_ptr<T>> init2 ( std::move(init) ) ;
    +assert ( init );
    +assert ( *init == nullptr );
    +assert ( init2 );
    +assert ( **init2 == T(2) ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&>::optional( + optional && + rhs ); +

+
    +
  • + Effect: Move-Constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is another reference to the same object + referenced by *rhs; + else *this + is uninitialized. +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: If rhs + is initialized, both *this and *rhs will refer to the same object + (they alias). +
  • +
  • + Example: +
    optional<std::unique_ptr<T>&> uninit ;
    +assert (!uninit);
    +
    +optional<std::unique_ptr<T>&> uinit2 ( std::move(uninit) ) ;
    +assert ( uninit2 == uninit );
    +
    +std::unique_ptr<T> v(new T(2)) ;
    +optional<std::unique_ptr<T>&> init(v);
    +assert ( *init == v ) ;
    +
    +optional<std::unique_ptr<T>&> init2 ( std::move(init) ) ;
    +assert ( *init2 == v ) ;
    +
    +*v = 3 ;
    +
    +assert ( **init  == 3 ) ;
    +assert ( **init2 == 3 ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> explicit optional<T + (not a ref)>::optional( + optional<U> const& rhs ); +

+
    +
  • + Effect: Copy-Constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is a copy of the + value of rhs converted to type T; + else *this + is uninitialized. +
  • +
  • + Throws: Whatever T::T( U const& + ) throws. +
  • +
  • + Notes: T::T( U const& + ) is called if rhs is initialized, which requires + a valid conversion from U + to T. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( U const& + ); in that case, this constructor + has no effect. +
  • +
  • + Example: +
    optional<double> x(123.4);
    +assert ( *x == 123.4 ) ;
    +
    +optional<int> y(x) ;
    +assert( *y == 123 ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> explicit optional<T + (not a ref)>::optional( + optional<U>&& + rhs ); +

+
    +
  • + Effect: Move-constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is move-constructed from *rhs; + else *this + is uninitialized. +
  • +
  • + Throws: Whatever T::T( U&& ) + throws. +
  • +
  • + Notes: T::T( U&& ) + is called if rhs is + initialized, which requires a valid conversion from U + to T. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( U&& ); + in that case, rhs remains + initialized and the value of *rhs is determined by exception safety + guarantee of T::T( U&& + ). +
  • +
  • + Example: +
    optional<double> x(123.4);
    +assert ( *x == 123.4 ) ;
    +
    +optional<int> y(std::move(x)) ;
    +assert( *y == 123 ) ;
    +
    +
  • +
+

+ space +

+

+ template<InPlaceFactory> + explicit optional<T + (not a ref)>::optional( + InPlaceFactory const& f ); +

+

+ template<TypedInPlaceFactory> + explicit optional<T + (not a ref)>::optional( + TypedInPlaceFactory const& f ); +

+
    +
  • + Effect: Constructs an optional with a value of T obtained from the factory. +
  • +
  • + Postconditions: *this is initialized + and its value is directly given from the factory + f (i.e., the value + is not copied). +
  • +
  • + Throws: Whatever the T constructor called by the factory + throws. +
  • +
  • + Notes: See In-Place + Factories +
  • +
  • + Exception Safety: Exceptions can only + be thrown during the call to the T + constructor used by the factory; in that case, this constructor has + no effect. +
  • +
  • + Example: +
    class C { C ( char, double, std::string ) ; } ;
    +
    +C v('A',123.4,"hello");
    +
    +optional<C> x( in_place   ('A', 123.4, "hello") ); // InPlaceFactory used
    +optional<C> y( in_place<C>('A', 123.4, "hello") ); // TypedInPlaceFactory used
    +
    +assert ( *x == v ) ;
    +assert ( *y == v ) ;
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T>::operator= ( none_t + ) noexcept; +

+
    +
  • + Effect: If *this is initialized destroys its contained + value. +
  • +
  • + Postconditions: *this is uninitialized. +
  • +
+

+ space +

+

+ optional& + optional<T (not a ref)>::operator= ( T + const& + rhs ) + ; +

+
    +
  • + Effect: Assigns the value rhs to an optional. +
  • +
  • + Postconditions: *this is initialized and its value is + a copy of rhs. +
  • +
  • + Throws: Whatever T::operator=( T const& + ) or T::T(T const&) + throws. +
  • +
  • + Notes: If *this was initialized, T's assignment operator is used, + otherwise, its copy-constructor is used. +
  • +
  • + Exception Safety: In the event of + an exception, the initialization state of *this is unchanged and its value unspecified + as far as optional + is concerned (it is up to T's + operator=()). + If *this + is initially uninitialized and T's + copy constructor fails, *this is left properly uninitialized. +
  • +
  • + Example: +
    T x;
    +optional<T> def ;
    +optional<T> opt(x) ;
    +
    +T y;
    +def = y ;
    +assert ( *def == y ) ;
    +opt = y ;
    +assert ( *opt == y ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&>& + optional<T&>::operator= ( T& rhs + ) ; +

+
    +
  • + Effect: (Re)binds the wrapped reference. +
  • +
  • + Postconditions: *this is initialized and it references + the same object referenced by rhs. +
  • +
  • + Notes: If *this was initialized, it is rebound + to the new object. See here + for details on this behavior. +
  • +
  • + Example: +
    int a = 1 ;
    +int b = 2 ;
    +T& ra = a ;
    +T& rb = b ;
    +optional<int&> def ;
    +optional<int&> opt(ra) ;
    +
    +def = rb ; // binds 'def' to 'b' through 'rb'
    +assert ( *def == b ) ;
    +*def = a ; // changes the value of 'b' to a copy of the value of 'a'
    +assert ( b == a ) ;
    +int c = 3;
    +int& rc = c ;
    +opt = rc ; // REBINDS to 'c' through 'rc'
    +c = 4 ;
    +assert ( *opt == 4 ) ;
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T (not a ref)>::operator= ( T&& rhs + ) ; +

+
    +
  • + Effect: Moves the value rhs to an optional. +
  • +
  • + Postconditions: *this is initialized and its value is + moved from rhs. +
  • +
  • + Throws: Whatever T::operator=( T&& ) + or T::T(T &&) + throws. +
  • +
  • + Notes: If *this was initialized, T's move-assignment operator is used, + otherwise, its move-constructor is used. +
  • +
  • + Exception Safety: In the event of + an exception, the initialization state of *this is unchanged and its value unspecified + as far as optional + is concerned (it is up to T's + operator=()). + If *this + is initially uninitialized and T's + move constructor fails, *this is left properly uninitialized. +
  • +
  • + Example: +
    T x;
    +optional<T> def ;
    +optional<T> opt(x) ;
    +
    +T y1, y2, yR;
    +def = std::move(y1) ;
    +assert ( *def == yR ) ;
    +opt = std::move(y2) ;
    +assert ( *opt == yR ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&>& + optional<T&>::operator= ( T&& rhs + ) = + delete; +

+
  • + Notes: This assignment operator is + deleted. +
+

+ space +

+

+ optional& + optional<T (not a ref)>::operator= ( optional + const& + rhs ) + ; +

+
    +
  • + Requires: T + is CopyConstructible and CopyAssignable. +
  • +
  • +

    + Effects: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns *rhs + to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with *rhs +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this; +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Exception Safety: If any exception + is thrown, the initialization state of *this and rhs + remains unchanged. If an exception is thrown during the call to T's copy constructor, no effect. + If an exception is thrown during the call to T's + copy assignment, the state of its contained value is as defined by + the exception safety guarantee of T's + copy assignment. +
  • +
  • + Example: +
    T v;
    +optional<T> opt(v);
    +optional<T> def ;
    +
    +opt = def ;
    +assert ( !def ) ;
    +// previous value (copy of 'v') destroyed from within 'opt'.
    +
    +
  • +
+

+ space +

+

+ optional<T&> + & optional<T&>::operator= ( optional<T&> const& rhs + ) ; +

+
    +
  • + Effect: (Re)binds thee wrapped reference. +
  • +
  • + Postconditions: If *rhs is initialized, *this + is initialized and it references the same object referenced by *rhs; + otherwise, *this + is uninitialized (and references no object). +
  • +
  • + Notes: If *this was initialized and so is *rhs, + *this + is rebound to the new object. See here + for details on this behavior. +
  • +
  • + Example: +
    int a = 1 ;
    +int b = 2 ;
    +T& ra = a ;
    +T& rb = b ;
    +optional<int&> def ;
    +optional<int&> ora(ra) ;
    +optional<int&> orb(rb) ;
    +
    +def = orb ; // binds 'def' to 'b' through 'rb' wrapped within 'orb'
    +assert ( *def == b ) ;
    +*def = ora ; // changes the value of 'b' to a copy of the value of 'a'
    +assert ( b == a ) ;
    +int c = 3;
    +int& rc = c ;
    +optional<int&> orc(rc) ;
    +ora = orc ; // REBINDS ora to 'c' through 'rc'
    +c = 4 ;
    +assert ( *ora == 4 ) ;
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T (not a ref)>::operator= ( optional&& rhs + ) noexcept(see below); +

+
    +
  • + Requires: T + is MoveConstructible + and MoveAssignable. +
  • +
  • +

    + Effects: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns std::move(*rhs) to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with std::move(*rhs) +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this; +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Remarks: The expression inside noexcept is equivalent to is_nothrow_move_constructible<T>::value && + is_nothrow_move_assignable<T>::value. +
  • +
  • + Exception Safety: If any exception + is thrown, the initialization state of *this and rhs + remains unchanged. If an exception is thrown during the call to T's move constructor, the state of + *rhs + is determined by the exception safety guarantee of T's + move constructor. If an exception is thrown during the call to T's + move-assignment, the state of **this and *rhs is determined by the exception + safety guarantee of T's move assignment. +
  • +
  • + Example: +
    optional<T> opt(T(2)) ;
    +optional<T> def ;
    +
    +opt = def ;
    +assert ( def ) ;
    +assert ( opt ) ;
    +assert ( *opt == T(2) ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T&> + & optional<T&>::operator= ( optional<T&>&& rhs + ) ; +

+
  • + Effect: Same as optional<T&>::operator= ( optional<T&> + const& + rhs ). +
+

+ space +

+

+ template<U> optional& + optional<T (not a ref)>::operator= ( optional<U> const& rhs + ) ; +

+
    +
  • +

    + Effect: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns *rhs + to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with *rhs +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this. +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Exception Safety: If any exception + is thrown, the result of the expression bool(*this) remains unchanged. If an exception + is thrown during the call to T's + constructor, no effect. If an exception is thrown during the call to + T's assignment, the + state of its contained value is as defined by the exception safety + guarantee of T's copy + assignment. +
  • +
  • + Example: +
    T v;
    +optional<T> opt0(v);
    +optional<U> opt1;
    +
    +opt1 = opt0 ;
    +assert ( *opt1 == static_cast<U>(v) ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> optional& + optional<T (not a ref)>::operator= ( optional<U>&& rhs + ) ; +

+
    +
  • +

    + Effect: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns std::move(*rhs) to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with std::move(*rhs) +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this. +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Exception Safety: If any exception + is thrown, the result of the expression bool(*this) remains unchanged. If an exception + is thrown during the call to T's + constructor, no effect. If an exception is thrown during the call to + T's assignment, the + state of its contained value is as defined by the exception safety + guarantee of T's copy + assignment. +
  • +
  • + Example: +
    T v;
    +optional<T> opt0(v);
    +optional<U> opt1;
    +
    +opt1 = std::move(opt0) ;
    +assert ( opt0 );
    +assert ( opt1 )
    +assert ( *opt1 == static_cast<U>(v) ) ;
    +
    +
  • +
+

+ space +

+

+ template<class... Args> + void optional<T + (not a ref)>::emplace( + Args...&& + args ); +

+
    +
  • + Requires: The compiler supports rvalue + references and variadic templates. +
  • +
  • + Effect: If *this is initialized calls *this = none. + Then initializes in-place the contained value as if direct-initializing + an object of type T + with std::forward<Args>(args).... +
  • +
  • + Postconditions: *this is initialized. +
  • +
  • + Throws: Whatever the selected T's constructor throws. +
  • +
  • + Exception Safety: If an exception + is thrown during the initialization of T, + *this + is uninitialized. +
  • +
  • + Notes: T + need not be MoveConstructible + or MoveAssignable. + On compilers that do not support variadic templates, the signature + falls back to two overloads:template<class + Arg> + void emplace(Arg&& arg) and void + emplace(). + On compilers that do not support rvalue references, the signature falls + back to three overloads: taking const + and non-const lvalue reference, + and third with empty function argument list. +
  • +
  • + Example: +
    T v;
    +optional<const T> opt;
    +opt.emplace(0);  // create in-place using ctor T(int)
    +opt.emplace();   // destroy previous and default-construct another T
    +opt.emplace(v);  // destroy and copy-construct in-place (no assignment called)
    +
    +
  • +
+

+ space +

+

+ template<InPlaceFactory> + optional<T>& + optional<T (not a ref)>::operator=( InPlaceFactory + const& + f ); +

+

+ template<TypedInPlaceFactory> + optional<T>& + optional<T (not a ref)>::operator=( TypedInPlaceFactory + const& + f ); +

+
    +
  • + Effect: Assigns an optional + with a value of T obtained + from the factory. +
  • +
  • + Postconditions: *this is initialized + and its value is directly given from the factory + f (i.e., the value + is not copied). +
  • +
  • + Throws: Whatever the T constructor called by the factory + throws. +
  • +
  • + Notes: See In-Place + Factories +
  • +
  • + Exception Safety: Exceptions can only + be thrown during the call to the T + constructor used by the factory; in that case, the optional + object will be reset to be uninitialized. +
  • +
+

+ space +

+

+ void optional<T + (not a ref)>::reset( T const& v ) ; +

+
  • + Deprecated: same as operator= + ( T + const& + v) + ; +
+

+ space +

+

+ void optional<T>::reset() noexcept + ; +

+
  • + Deprecated: Same as operator=( + none_t ); +
+

+ space +

+

+ T const& optional<T + (not a ref)>::get() const ; +

+

+ T& + optional<T (not a ref)>::get() ; +

+

+ inline T + const& + get ( + optional<T (not a ref)> const& ) ; +

+

+ inline T& get + ( optional<T + (not a ref)> + &) ; +

+
    +
  • + Requires: *this is initialized +
  • +
  • + Returns: A reference to the contained + value +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). +
  • +
+

+ space +

+

+ T const& optional<T&>::get() const ; +

+

+ T& + optional<T&>::get() ; +

+

+ inline T + const& + get ( + optional<T&> + const& + ) ; +

+

+ inline T& get + ( optional<T&> &) + ; +

+
    +
  • + Requires: *this is initialized +
  • +
  • + Returns: The + reference contained. +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). +
  • +
+

+ space +

+

+ T const& optional<T + (not a ref)>::operator*() + const& + ; +

+

+ T& + optional<T (not a ref)>::operator*() &; +

+
    +
  • + Requires: *this is initialized +
  • +
  • + Returns: A reference to the contained + value +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). + On compilers that do not support ref-qualifiers on member functions + these two overloads are replaced with the classical two: a const and non-const + member functions. +
  • +
  • + Example: +
    T v ;
    +optional<T> opt ( v );
    +T const& u = *opt;
    +assert ( u == v ) ;
    +T w ;
    +*opt = w ;
    +assert ( *opt == w ) ;
    +
    +
  • +
+

+ space +

+

+ T&& + optional<T (not a ref)>::operator*() &&; +

+
    +
  • + Requires: *this contains a value. +
  • +
  • + Effects: Equivalent to return std::move(*val);. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). + On compilers that do not support ref-qualifiers on member functions + this overload is not present. +
  • +
+

+ space +

+

+ T & + optional<T&>::operator*() + const& + ; +

+

+ T & + optional<T&>::operator*() + & ; +

+

+ T & + optional<T&>::operator*() + && ; +

+
    +
  • + Requires: *this is initialized +
  • +
  • + Returns: The + reference contained. +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). + On compilers that do not support ref-qualifiers on member functions + these three overloads are replaced with the classical two: a const and non-const + member functions. +
  • +
  • + Example: +
    T v ;
    +T& vref = v ;
    +optional<T&> opt ( vref );
    +T const& vref2 = *opt;
    +assert ( vref2 == v ) ;
    +++ v ;
    +assert ( *opt == v ) ;
    +
    +
  • +
+

+ space +

+

+ T const& optional<T>::value() const& ; +

+

+ T& + optional<T>::value() & ; +

+
    +
  • + Effects: Equivalent to return bool(*this) ? *val : throw bad_optional_access();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions these two overloads are replaced + with the classical two: a const + and non-const member functions. +
  • +
  • + Example: +
    T v ;
    +optional<T> o0, o1 ( v );
    +assert ( o1.value() == v );
    +
    +try {
    +  o0.value(); // throws
    +  assert ( false );
    +}
    +catch(bad_optional_access&) {
    +  assert ( true );
    +}
    +
    +
  • +
+

+ space +

+

+ T&& + optional<T>::value() && ; +

+
    +
  • + Effects: Equivalent to return bool(*this) ? std::move(*val) : throw bad_optional_access();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is not present. +
  • +
+

+ space +

+

+ template<class U> T optional<T>::value_or(U && + v) + const& + ; +

+
    +
  • + Effects: Equivalent to if (*this) return **this; else return + std::forward<U>(v);. +
  • +
  • + Remarks: If T + is not CopyConstructible or U && + is not convertible to T, + the program is ill-formed. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is replaced with the + const-qualified member + function. On compilers without rvalue reference support the type of + v becomes U const&. +
  • +
+

+ space +

+

+ template<class U> T optional<T>::value_or(U && + v) + && ; +

+
    +
  • + Effects: Equivalent to if (*this) return std::move(**this); else return std::forward<U>(v);. +
  • +
  • + Remarks: If T + is not MoveConstructible + or U && + is not convertible to T, + the program is ill-formed. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is not present. +
  • +
+

+ space +

+

+ template<class F> T optional<T>::value_or_eval(F f) const& ; +

+
    +
  • + Requires: T + is CopyConstructible and F models a Generator whose result type + is convertible to T. +
  • +
  • + Effects: if + (*this) return **this; else return f();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is replaced with the + const-qualified member + function. +
  • +
  • + Example: +
    int complain_and_0()
    +{
    +  clog << "no value returned, using default" << endl;
    +  return 0;
    +}
    +
    +optional<int> o1 = 1;
    +optional<int> oN = none;
    +
    +int i = o1.value_or_eval(complain_and_0); // fun not called
    +assert (i == 1);
    +
    +int j = oN.value_or_eval(complain_and_0); // fun called
    +assert (i == 0);
    +
    +
  • +
+

+ space +

+

+ template<class F> T optional<T>::value_or_eval(F f) && + ; +

+
    +
  • + Requires: T + is MoveConstructible + and F models a Generator + whose result type is convertible to T. +
  • +
  • + Effects: if + (*this) return std::move(**this); else return + f();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is not present. +
  • +
+

+ space +

+

+ T const& optional<T + (not a ref)>::get_value_or( + T const& default) const ; +

+

+ T& + optional<T (not a ref)>::get_value_or( T& default + ) ; +

+

+ inline T + const& + get_optional_value_or ( + optional<T (not a ref)> const& o, T const& default ) ; +

+

+ inline T& get_optional_value_or + ( optional<T + (not a ref)>& + o, + T& + default ) + ; +

+
    +
  • + Deprecated: Use value_or() instead. +
  • +
  • + Returns: A reference to the contained + value, if any, or default. +
  • +
  • + Throws: Nothing. +
  • +
  • + Example: +
    T v, z ;
    +optional<T> def;
    +T const& y = def.get_value_or(z);
    +assert ( y == z ) ;
    +
    +optional<T> opt ( v );
    +T const& u = get_optional_value_or(opt,z);
    +assert ( u == v ) ;
    +assert ( u != z ) ;
    +
    +
  • +
+

+ space +

+

+ T const* optional<T + (not a ref)>::get_ptr() + const ; +

+

+ T* + optional<T (not a ref)>::get_ptr() ; +

+

+ inline T + const* + get_pointer ( + optional<T (not a ref)> const& ) ; +

+

+ inline T* get_pointer + ( optional<T + (not a ref)> + &) ; +

+
    +
  • + Returns: If *this is initialized, a pointer to the + contained value; else 0 + (null). +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The contained value is permanently + stored within *this, + so you should not hold nor delete this pointer +
  • +
  • + Example: +
    T v;
    +optional<T> opt(v);
    +optional<T> const copt(v);
    +T* p = opt.get_ptr() ;
    +T const* cp = copt.get_ptr();
    +assert ( p == get_pointer(opt) );
    +assert ( cp == get_pointer(copt) ) ;
    +
    +
  • +
+

+ space +

+

+ T const* optional<T + (not a ref)>::operator ->() + const ; +

+

+ T* + optional<T (not a ref)>::operator + ->() ; +

+
    +
  • + Requires: *this is initialized. +
  • +
  • + Returns: A pointer to the contained + value. +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). +
  • +
  • + Example: +
    struct X { int mdata ; } ;
    +X x ;
    +optional<X> opt (x);
    +opt->mdata = 2 ;
    +
    +
  • +
+

+ space +

+

+ explicit optional<T>::operator + bool() + const noexcept + ; +

+
    +
  • + Returns: get_ptr() != 0. +
  • +
  • + Notes: On compilers that do not support + explicit conversion operators this falls back to safe-bool idiom. +
  • +
  • + Example: +
    optional<T> def ;
    +assert ( def == 0 );
    +optional<T> opt ( v ) ;
    +assert ( opt );
    +assert ( opt != 0 );
    +
    +
  • +
+

+ space +

+

+ bool optional<T>::operator!() noexcept + ; +

+
    +
  • + Returns: If *this is uninitialized, true; else false. +
  • +
  • + Notes: This operator is provided for + those compilers which can't use the unspecified-bool-type + operator in certain boolean contexts. +
  • +
  • + Example: +
    optional<T> opt ;
    +assert ( !opt );
    +*opt = some_T ;
    +
    +// Notice the "double-bang" idiom here.
    +assert ( !!opt ) ;
    +
    +
  • +
+

+ space +

+

+ bool optional<T>::is_initialized() const ; +

+
  • + Deprecated: Same as explicit operator + bool () + ; +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html new file mode 100644 index 0000000..f786277 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___free_functions.html @@ -0,0 +1,497 @@ + + + +Detailed Semantics - Free Functions + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ space +

+

+ optional<T> make_optional( + T const& v ) +

+
    +
  • + Returns: optional<T>(v) for the deduced + type T of v. +
  • +
  • + Example: +
    template<class T> void foo ( optional<T> const& opt ) ;
    +
    +foo ( make_optional(1+1) ) ; // Creates an optional<int>
    +
    +
  • +
+

+ space +

+

+ optional<T> make_optional( + bool condition, T const& v ) +

+
    +
  • + Returns: optional<T>(condition, v) for the deduced + type T of v. +
  • +
  • + Example: +
    optional<double> calculate_foo()
    +{
    +  double val = compute_foo();
    +  return make_optional(is_not_nan_and_finite(val),val);
    +}
    +
    +optional<double> v = calculate_foo();
    +if ( !v )
    +  error("foo wasn't computed");
    +
    +
  • +
+

+ space +

+

+ bool operator + == ( + optional<T> const& x, optional<T> const& y ); +

+
    +
  • + Requires: T + shall meet requirements of EqualityComparable. +
  • +
  • + Returns: If both x + and y are initialized, + (*x + == *y). + If only x or y is initialized, false. + If both are uninitialized, true. +
  • +
  • + Notes: This definition guarantees + that optional<T> + not containing a value is compared unequal to any optional<T> containing any value, and equal + to any other optional<T> not containing a value. Pointers + have shallow relational operators while optional + has deep relational operators. Do not use operator== directly in generic code which expect + to be given either an optional<T> or a pointer; use equal_pointees() + instead +
  • +
  • + Example: +
    optional<T> oN, oN_;
    +optional<T> o1(T(1)), o1_(T(1));
    +optional<T> o2(T(2));
    +
    +assert ( oN == oN );  // Identity implies equality
    +assert ( o1 == o1 );  //
    +
    +assert ( oN == oN_ ); // Both uninitialized compare equal
    +
    +assert ( oN != o1 );  // Initialized unequal to initialized.
    +
    +assert ( o1 == o1_ ); // Both initialized compare as (*lhs == *rhs)
    +assert ( o1 != o2 );  //
    +
    +
  • +
+

+ space +

+

+ bool operator + < ( + optional<T> const& x, optional<T> const& y ); +

+
    +
  • + Requires: Expression *x < *y shall be well-formed and its result + shall be convertible to bool. +
  • +
  • + Returns: (!y) ? false : (!x) ? true : *x < + *y. +
  • +
  • + Notes: This definition guarantees + that optional<T> + not containing a value is ordered as less than any optional<T> containing any value, and equivalent + to any other optional<T> not containing a value. Pointers + have shallow relational operators while optional + has deep relational operators. Do not use operator< directly in generic code which + expect to be given either an optional<T> or a pointer; use less_pointees() + instead. T need not + be LessThanComparable. Only + single operator< + is required. Other relational operations are defined in terms of this + one. If T's operator< + satisfies the axioms of LessThanComparable (transitivity, + antisymmetry and irreflexivity), optinal<T> is LessThanComparable. +
  • +
  • + Example: +
    optional<T> oN, oN_;
    +optional<T> o0(T(0));
    +optional<T> o1(T(1));
    +
    +assert ( !(oN < oN) );  // Identity implies equivalence
    +assert ( !(o1 < o1) );
    +
    +assert ( !(oN < oN_) ); // Two uninitialized are equivalent
    +assert ( !(oN_ < oN) );
    +
    +assert ( oN < o0 );     // Uninitialized is less than initialized
    +assert ( !(o0 < oN) );
    +
    +assert ( o1 < o2 ) ;    // Two initialized compare as (*lhs < *rhs)
    +assert ( !(o2 < o1) ) ;
    +assert ( !(o2 < o2) ) ;
    +
    +
  • +
+

+ space +

+

+ bool operator + != ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: !( + x == + y ); +
+

+ space +

+

+ bool operator + > ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: ( + y < + x ); +
+

+ space +

+

+ bool operator + <= ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: !( + y < + x ); +
+

+ space +

+

+ bool operator + >= ( + optional<T> const& x, optional<T> const& y ); +

+
  • + Returns: !( + x < + y ); +
+

+ space +

+

+ bool operator + == ( + optional<T> const& x, none_t ) + noexcept; +

+

+ bool operator + == ( + none_t, + optional<T> const& x ) noexcept; +

+
+

+ space +

+

+ bool operator + != ( + optional<T> const& x, none_t ) + noexcept; +

+

+ bool operator + != ( + none_t, + optional<T> const& x ) noexcept; +

+
  • + Returns: !( + x == + y ); +
+

+ space +

+

+ auto get_pointer + ( optional<T>& o + ) -> + typename optional<T>::pointer_type + ; +

+

+ auto get_pointer + ( optional<T> const& o ) -> typename optional<T>::pointer_const_type + ; +

+
    +
  • + Returns: o.get_ptr(). +
  • +
  • + Throws: Nothing. +
  • +
+

+ space +

+

+ auto get_optional_value_or + ( optional<T>& o, typename optional<T>::reference_type def + ) -> + typename optional<T>::reference_type + ; +

+

+ auto get_optional_value_or + ( optional<T> const& o, typename optional<T>::reference_const_type def + ) -> + typename optional<T>::reference_const_type + ; +

+
    +
  • + Returns: o.get_value_or(def). +
  • +
  • + Throws: Nothing. +
  • +
  • + Remarks: This function is deprecated. +
  • +
+

+ space +

+

+ void swap + ( optional<T>& x, optional<T>& y + ) ; +

+
    +
  • + Requires: Lvalues of type T shall be swappable and T shall be MoveConstructible. +
  • +
  • +

    + Effects: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + calls swap(*(*this), *rhs) +

    +
    +

    + initializes the contained value of *this as if direct-initializing + an object of type T + with the expression std::move(*rhs), followed by rhs.val->T::~T(), + *this + contains a value and rhs + does not contain a value +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + initializes the contained value of rhs + as if direct-initializing an object of type T with the expression + std::move(*(*this)), + followed by val->T::~T(), *this does not contain a value + and rhs contains + a value +

    +
    +

    + no effect +

    +
    +
  • +
  • + Postconditions: The states of x and y + interchanged. +
  • +
  • + Throws: If both are initialized, whatever + swap(T&,T&) + throws. If only one is initialized, whatever T::T ( T&& ) + throws. +
  • +
  • + Example: +
    T x(12);
    +T y(21);
    +optional<T> def0 ;
    +optional<T> def1 ;
    +optional<T> optX(x);
    +optional<T> optY(y);
    +
    +boost::swap(def0,def1); // no-op
    +
    +boost::swap(def0,optX);
    +assert ( *def0 == x );
    +assert ( !optX );
    +
    +boost::swap(def0,optX); // Get back to original values
    +
    +boost::swap(optX,optY);
    +assert ( *optX == y );
    +assert ( *optY == x );
    +
    +
  • +
+

+ space +

+

+ void swap + ( optional<T&>& x, optional<T&>& y + ) noexcept + ; +

+
    +
  • + Postconditions: x + refers to what y refererred + to before the swap (if anything). y + refers to whatever x + referred to before the swap. +
  • +
  • + Example: +
    T x(12);
    +T y(21);
    +
    +optional<T&> opt0;
    +optional<T&> optX (x);
    +optional<T&> optY (y);
    +
    +boost::swap(optX, optY);
    +assert (addressof(*optX) == addressof(y));
    +assert (addressof(*optY) == addressof(x));
    +
    +boost::swap(opt0, optX);
    +assert ( opt0 );
    +assert ( !optX );
    +assert (addressof(*opt0) == addressof(y));
    +
    +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html new file mode 100644 index 0000000..05e3e21 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_references.html @@ -0,0 +1,509 @@ + + + +Detailed Semantics - Optional References + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ space +

+

+ optional<T&>::optional() + noexcept; +

+

+ optional<T&>::optional(none_t) noexcept; +

+
  • + Postconditions: bool(*this) == false; *this refers to nothing. +
+

+ space +

+

+ template<class R> optional<T&>::optional(R&& r) noexcept; +

+
    +
  • + Postconditions: bool(*this) == true; addressof(**this) == addressof(r). +
  • +
  • + Remarks: Unless R + is an lvalue reference, the program is ill-formed. This constructor + does not participate in overload resolution if decay<R> is an instance of boost::optional. +
  • +
  • + Example: +
    T v;
    +T& vref = v ;
    +optional<T&> opt(vref);
    +assert ( *opt == v ) ;
    +++ v ; // mutate referee
    +assert (*opt == v);
    +
    +
  • +
+

+ space +

+

+ template<class R> optional<T&>::optional(bool cond, R&& + r) + noexcept; +

+
    +
  • + Effects: Initializes ref with expression cond ? + addressof(r) : nullptr. +
  • +
  • + Postconditions: bool(*this) == cond; If bool(*this), addressof(**this) == addressof(r). +
  • +
  • + Remarks: Unless R + is an lvalue reference, the program is ill-formed. This constructor + does not participate in overload resolution if decay<R> is an instance of boost::optional. +
  • +
+

+ space +

+

+ optional<T&>::optional ( + optional const& rhs + ) noexcept + ; +

+
    +
  • + Effects: Initializes ref with expression rhs.ref. +
  • +
  • + Postconditions: bool(*this) == bool(rhs). +
  • +
  • + Example: +
    optional<T&> uninit ;
    +assert (!uninit);
    +
    +optional<T&> uinit2 ( uninit ) ;
    +assert ( uninit2 == uninit );
    +
    +T v = 2 ; T& ref = v ;
    +optional<T> init(ref);
    +assert ( *init == v ) ;
    +
    +optional<T> init2 ( init ) ;
    +assert ( *init2 == v ) ;
    +
    +v = 3 ;
    +
    +assert ( *init  == 3 ) ;
    +assert ( *init2 == 3 ) ;
    +
    +
  • +
+

+ space +

+

+ template<class U> explicit + optional<T&>::optional ( + optional<U&> + const& + rhs ) + noexcept ; +

+
    +
  • + Requires: is_convertible<U&, T&>::value + is true. +
  • +
  • + Effects: Initializes ref with expression rhs.ref. +
  • +
  • + Postconditions: bool(*this) == bool(rhs). +
  • +
+

+ space +

+

+ optional<T&>::operator= ( none_t + ) noexcept + ; +

+
    +
  • + Effects: Assigns ref + with expression nullptr. +
  • +
  • + returns: *this. +
  • +
  • + Postconditions: bool(*this) == false. +
  • +
+

+ optional& + optional<T&>::operator= ( optional + const& + rhs ) + noexcept ; +

+
    +
  • + Effects: Assigns ref + with expression rhs.ref. +
  • +
  • + returns: *this. +
  • +
  • + Postconditions: bool(*this) == bool(rhs). +
  • +
  • + Notes: This behaviour is called rebinding + semantics. See here + for details. +
  • +
  • + Example: +
    int a = 1 ;
    +int b = 2 ;
    +T& ra = a ;
    +T& rb = b ;
    +optional<int&> def ;
    +optional<int&> ora(ra) ;
    +optional<int&> orb(rb) ;
    +
    +def = orb ; // binds 'def' to 'b' through 'rb' wrapped within 'orb'
    +assert ( *def == b ) ;
    +*def = ora ; // changes the value of 'b' to a copy of the value of 'a'
    +assert ( b == a ) ;
    +int c = 3;
    +int& rc = c ;
    +optional<int&> orc(rc) ;
    +ora = orc ; // REBINDS ora to 'c' through 'rc'
    +c = 4 ;
    +assert ( *ora == 4 ) ;
    +
    +
  • +
+

+ template<class U> optional& optional<T&>::operator= ( optional<U&> const& rhs + ) noexcept + ; +

+
    +
  • + Requires: is_convertible<U&, T&>::value + is true. +
  • +
  • + Effects: Assigns ref + with expression rhs.ref. +
  • +
  • + returns: *this. +
  • +
  • + Postconditions: bool(*this) == bool(rhs). +
  • +
+

+ space +

+

+ template<class R> optional& optional<T&>::operator= ( R&& r + ) noexcept + ; +

+
    +
  • + Effects: Assigns ref + with expression r. +
  • +
  • + returns: *this. +
  • +
  • + Postconditions: bool(*this) == true. +
  • +
  • + Remarks: Unless R + is an lvalue reference, the program is ill-formed. This function does + not participate in overload resolution if decay<R> is an instance of boost::optional. +
  • +
  • + Example: +
    int a = 1 ;
    +int b = 2 ;
    +T& ra = a ;
    +T& rb = b ;
    +optional<int&> def ;
    +optional<int&> opt(ra) ;
    +
    +def = rb ; // binds 'def' to 'b' through 'rb'
    +assert ( *def == b ) ;
    +*def = a ; // changes the value of 'b' to a copy of the value of 'a'
    +assert ( b == a ) ;
    +int c = 3;
    +int& rc = c ;
    +opt = rc ; // REBINDS to 'c' through 'rc'
    +c = 4 ;
    +assert ( *opt == 4 ) ;
    +
    +
  • +
+

+ space +

+

+ void optional<T&>::emplace( R&& r + ) noexcept + ; +

+
    +
  • + Effects: Assigns ref + with expression r. +
  • +
  • + Postconditions: bool(*this) == true. +
  • +
  • + Remarks: Unless R + is an lvalue reference, the program is ill-formed. This function does + not participate in overload resolution if decay<R> is an instance of boost::optional. +
  • +
+

+ space +

+

+ T& + optional<T&>::get() const ; +

+

+ T& + optional<T&>::operator *() + const ; +

+
    +
  • + Requires: bool(*this) == true. +
  • +
  • + Effects: Returns *ref. +
  • +
  • + Throws: Nothing. +
  • +
  • + Example: +
    T v ;
    +T& vref = v ;
    +optional<T&> opt ( vref );
    +T const& vref2 = *opt;
    +assert ( vref2 == v ) ;
    +++ v ;
    +assert ( *opt == v ) ;
    +
    +
  • +
+

+ space +

+

+ T* + optional<T&>::operator -> + () const + ; +

+
    +
  • + Requires: bool(*this) == true. +
  • +
  • + Effects: Returns ref. +
  • +
  • + Throws: Nothing. +
  • +
+

+ space +

+

+ T& + optional<T&>::value() const ; +

+
  • + Effects: Equivalent to return bool(*this) ? *val : throw bad_optional_access();. +
+

+ space +

+

+ template<class R> T& optional<T&>::value_or( R&& r + ) const + noexcept; +

+
    +
  • + Effects: Equivalent to if (*this) return **this; else return + r;. +
  • +
  • + Remarks: Unless R + is an lvalue reference, the program is ill-formed. +
  • +
+

+ space +

+

+ template<class F> T& optional<T&>::value_or( F f ) const ; +

+
    +
  • + Effects: Equivalent to if (*this) return **this; else return + f();. +
  • +
  • + Remarks: Unless decltype(f()) is an lvalue reference, the program + is ill-formed. +
  • +
+

+ space +

+

+ T* + optional<T&>::get_ptr () + const noexcept; +

+
  • + Returns: ref. +
+

+ space +

+

+ optional<T&>::operator bool + () const + noexcept; +

+
  • + Returns: bool(ref). +
+

+ space +

+

+ optional<T&>::operator ! () const noexcept; +

+
  • + Returns: !bool(ref). +
+

+ space +

+

+ void optional<T&>::reset() noexcept; +

+
    +
  • + Effects: Use *this = none instead. +
  • +
  • + Remarks: This function is depprecated. +
  • +
+

+ space +

+

+ template<class R> void optional<T&>::reset ( R&& + r) + noexcept; +

+
    +
  • + Effects: Equivalent to *this = std::forward<R>(r). +
  • +
  • + Remarks: This function is depprecated. +
  • +
+

+ space +

+

+ bool optional<T&>::is_initialized() const noexcept; +

+
    +
  • + Effects: Equivalent to return bool(*this). +
  • +
  • + Remarks: This function is depprecated. +
  • +
+

+ space +

+

+ template<class R> T& optional<T&>::get_value_or( R&& r + ) const + noexcept; +

+
    +
  • + Effects: Equivalent to return value_or(std::forward<R>(r);. +
  • +
  • + Remarks: This function is depprecated. +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html new file mode 100644 index 0000000..a33ad48 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/detailed_semantics___optional_values.html @@ -0,0 +1,1584 @@ + + + +Detailed Semantics - Optional Values + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + + + + +
[Note]Note

+ The following section contains various assert() which are used only to show the postconditions + as sample code. It is not implied that the type T + must support each particular expression but that if the expression is + supported, the implied condition holds. +

+

+ space +

+

+ optional<T>::optional() + noexcept; +

+
    +
  • + Effect: Default-Constructs an optional. +
  • +
  • + Postconditions: *this is uninitialized. +
  • +
  • + Notes: T's default constructor is not called. +
  • +
  • + Example: +
    optional<T> def ;
    +assert ( !def ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T>::optional( + none_t ) + noexcept; +

+
    +
  • + Effect: Constructs an optional uninitialized. +
  • +
  • + Postconditions: *this is uninitialized. +
  • +
  • + Notes: T's + default constructor is not called. + The expression boost::none + denotes an instance of boost::none_t + that can be used as the parameter. +
  • +
  • + Example: +
    #include <boost/none.hpp>
    +optional<T> n(none) ;
    +assert ( !n ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T>::optional( + T const& v ) +

+
    +
  • + Requires: is_copy_constructible<T>::value + is true. +
  • +
  • + Effect: Directly-Constructs an optional. +
  • +
  • + Postconditions: *this is initialized + and its value is a copy of v. +
  • +
  • + Throws: Whatever T::T( T const& + ) throws. +
  • +
  • + Notes: T::T( T const& + ) is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T const& + ); in that case, this constructor + has no effect. +
  • +
  • + Example: +
    T v;
    +optional<T> opt(v);
    +assert ( *opt == v ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T>::optional( + T&& + v ) +

+
    +
  • + Requires: is_move_constructible<T>::value + is true. +
  • +
  • + Effect: Directly-Move-Constructs an + optional. +
  • +
  • + Postconditions: *this is initialized + and its value is move-constructed from v. +
  • +
  • + Throws: Whatever T::T( T&& ) + throws. +
  • +
  • + Notes: T::T( T&& ) + is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T&& ); + in that case, the state of v + is determined by exception safety guarantees for T::T(T&&). +
  • +
  • + Example: +
    T v1, v2;
    +optional<T> opt(std::move(v1));
    +assert ( *opt == v2 ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T>::optional( + bool condition, T const& v ) ; +

+
  • + If condition is true, same as: +
+

+ optional<T>::optional( + T const& v ) +

+
  • + otherwise, same as: +
+

+ optional<T>::optional() +

+

+ space +

+

+ optional<T>::optional( + optional const& rhs + ); +

+
    +
  • + Requires: is_copy_constructible<T>::value + is true. +
  • +
  • + Effect: Copy-Constructs an optional. +
  • +
  • + Postconditions: If rhs is initialized, + *this + is initialized and its value is a copy of the + value of rhs; else + *this + is uninitialized. +
  • +
  • + Throws: Whatever T::T( T const& + ) throws. +
  • +
  • + Notes: If rhs is initialized, T::T(T const& ) + is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T const& + ); in that case, this constructor + has no effect. +
  • +
  • + Example: +
    optional<T> uninit ;
    +assert (!uninit);
    +
    +optional<T> uinit2 ( uninit ) ;
    +assert ( uninit2 == uninit );
    +
    +optional<T> init( T(2) );
    +assert ( *init == T(2) ) ;
    +
    +optional<T> init2 ( init ) ;
    +assert ( init2 == init ) ;
    +
    +
  • +
+

+ space +

+

+ optional<T>::optional( + optional&& + rhs ) + noexcept(see + below); +

+
    +
  • + Requires: is_move_constructible<T>::value + is true. +
  • +
  • + Effect: Move-constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is move constructed from rhs; else *this is uninitialized. +
  • +
  • + Throws: Whatever T::T( T&& ) + throws. +
  • +
  • + Remarks: The expression inside noexcept is equivalent to is_nothrow_move_constructible<T>::value. +
  • +
  • + Notes: If rhs + is initialized, T::T( T && + ) is called. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( T&& ); + in that case, rhs remains + initialized and the value of *rhs is determined by exception safety + of T::T(T&&). +
  • +
  • + Example: +
    optional<std::unique_ptr<T>> uninit ;
    +assert (!uninit);
    +
    +optional<std::unique_ptr<T>> uinit2 ( std::move(uninit) ) ;
    +assert ( uninit2 == uninit );
    +
    +optional<std::unique_ptr<T>> init( std::uniqye_ptr<T>(new T(2)) );
    +assert ( **init == T(2) ) ;
    +
    +optional<std::unique_ptr<T>> init2 ( std::move(init) ) ;
    +assert ( init );
    +assert ( *init == nullptr );
    +assert ( init2 );
    +assert ( **init2 == T(2) ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> explicit optional<T>::optional( optional<U> const& rhs + ); +

+
    +
  • + Effect: Copy-Constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is a copy of the + value of rhs converted to type T; + else *this + is uninitialized. +
  • +
  • + Throws: Whatever T::T( U const& + ) throws. +
  • +
  • + Notes: T::T( U const& + ) is called if rhs is initialized, which requires + a valid conversion from U + to T. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( U const& + ); in that case, this constructor + has no effect. +
  • +
  • + Example: +
    optional<double> x(123.4);
    +assert ( *x == 123.4 ) ;
    +
    +optional<int> y(x) ;
    +assert( *y == 123 ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> explicit optional<T>::optional( optional<U>&& rhs + ); +

+
    +
  • + Effect: Move-constructs an optional. +
  • +
  • + Postconditions: If rhs + is initialized, *this + is initialized and its value is move-constructed from *rhs; + else *this + is uninitialized. +
  • +
  • + Throws: Whatever T::T( U&& ) + throws. +
  • +
  • + Notes: T::T( U&& ) + is called if rhs is + initialized, which requires a valid conversion from U + to T. +
  • +
  • + Exception Safety: Exceptions can only + be thrown during T::T( U&& ); + in that case, rhs remains + initialized and the value of *rhs is determined by exception safety + guarantee of T::T( U&& + ). +
  • +
  • + Example: +
    optional<double> x(123.4);
    +assert ( *x == 123.4 ) ;
    +
    +optional<int> y(std::move(x)) ;
    +assert( *y == 123 ) ;
    +
    +
  • +
+

+ space +

+

+ template<InPlaceFactory> + explicit optional<T>::optional( InPlaceFactory + const& + f ); +

+

+ template<TypedInPlaceFactory> + explicit optional<T>::optional( TypedInPlaceFactory + const& + f ); +

+
    +
  • + Effect: Constructs an optional with a value of T obtained from the factory. +
  • +
  • + Postconditions: *this is initialized + and its value is directly given from the factory + f (i.e., the value + is not copied). +
  • +
  • + Throws: Whatever the T constructor called by the factory + throws. +
  • +
  • + Notes: See In-Place + Factories +
  • +
  • + Exception Safety: Exceptions can only + be thrown during the call to the T + constructor used by the factory; in that case, this constructor has + no effect. +
  • +
  • + Example: +
    class C { C ( char, double, std::string ) ; } ;
    +
    +C v('A',123.4,"hello");
    +
    +optional<C> x( in_place   ('A', 123.4, "hello") ); // InPlaceFactory used
    +optional<C> y( in_place<C>('A', 123.4, "hello") ); // TypedInPlaceFactory used
    +
    +assert ( *x == v ) ;
    +assert ( *y == v ) ;
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T>::operator= ( none_t + ) noexcept; +

+
    +
  • + Effect: If *this is initialized destroys its contained + value. +
  • +
  • + Postconditions: *this is uninitialized. +
  • +
+

+ space +

+

+ optional& + optional<T>::operator= ( T const& rhs ) ; +

+
    +
  • + Effect: Assigns the value rhs to an optional. +
  • +
  • + Postconditions: *this is initialized and its value is + a copy of rhs. +
  • +
  • + Throws: Whatever T::operator=( T const& + ) or T::T(T const&) + throws. +
  • +
  • + Notes: If *this was initialized, T's assignment operator is used, + otherwise, its copy-constructor is used. +
  • +
  • + Exception Safety: In the event of + an exception, the initialization state of *this is unchanged and its value unspecified + as far as optional + is concerned (it is up to T's + operator=()). + If *this + is initially uninitialized and T's + copy constructor fails, *this is left properly uninitialized. +
  • +
  • + Example: +
    T x;
    +optional<T> def ;
    +optional<T> opt(x) ;
    +
    +T y;
    +def = y ;
    +assert ( *def == y ) ;
    +opt = y ;
    +assert ( *opt == y ) ;
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T>::operator= ( T&& rhs + ) ; +

+
    +
  • + Effect: Moves the value rhs to an optional. +
  • +
  • + Postconditions: *this is initialized and its value is + moved from rhs. +
  • +
  • + Throws: Whatever T::operator=( T&& ) + or T::T(T &&) + throws. +
  • +
  • + Notes: If *this was initialized, T's move-assignment operator is used, + otherwise, its move-constructor is used. +
  • +
  • + Exception Safety: In the event of + an exception, the initialization state of *this is unchanged and its value unspecified + as far as optional + is concerned (it is up to T's + operator=()). + If *this + is initially uninitialized and T's + move constructor fails, *this is left properly uninitialized. +
  • +
  • + Example: +
    T x;
    +optional<T> def ;
    +optional<T> opt(x) ;
    +
    +T y1, y2, yR;
    +def = std::move(y1) ;
    +assert ( *def == yR ) ;
    +opt = std::move(y2) ;
    +assert ( *opt == yR ) ;
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T>::operator= ( optional + const& + rhs ) + ; +

+
    +
  • + Requires: T + is CopyConstructible and CopyAssignable. +
  • +
  • +

    + Effects: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns *rhs + to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with *rhs +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this; +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Exception Safety: If any exception + is thrown, the initialization state of *this and rhs + remains unchanged. If an exception is thrown during the call to T's copy constructor, no effect. + If an exception is thrown during the call to T's + copy assignment, the state of its contained value is as defined by + the exception safety guarantee of T's + copy assignment. +
  • +
  • + Example: +
    T v;
    +optional<T> opt(v);
    +optional<T> def ;
    +
    +opt = def ;
    +assert ( !def ) ;
    +// previous value (copy of 'v') destroyed from within 'opt'.
    +
    +
  • +
+

+ space +

+

+ optional& + optional<T>::operator= ( optional&& rhs + ) noexcept(see below); +

+
    +
  • + Requires: T + is MoveConstructible + and MoveAssignable. +
  • +
  • +

    + Effects: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns std::move(*rhs) to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with std::move(*rhs) +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this; +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Remarks: The expression inside noexcept is equivalent to is_nothrow_move_constructible<T>::value && + is_nothrow_move_assignable<T>::value. +
  • +
  • + Exception Safety: If any exception + is thrown, the initialization state of *this and rhs + remains unchanged. If an exception is thrown during the call to T's move constructor, the state of + *rhs + is determined by the exception safety guarantee of T's + move constructor. If an exception is thrown during the call to T's + move-assignment, the state of **this and *rhs is determined by the exception + safety guarantee of T's move assignment. +
  • +
  • + Example: +
    optional<T> opt(T(2)) ;
    +optional<T> def ;
    +
    +opt = def ;
    +assert ( def ) ;
    +assert ( opt ) ;
    +assert ( *opt == T(2) ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> optional& + optional<T>::operator= ( optional<U> const& rhs + ) ; +

+
    +
  • +

    + Effect: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns *rhs + to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with *rhs +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this. +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Exception Safety: If any exception + is thrown, the result of the expression bool(*this) remains unchanged. If an exception + is thrown during the call to T's + constructor, no effect. If an exception is thrown during the call to + T's assignment, the + state of its contained value is as defined by the exception safety + guarantee of T's copy + assignment. +
  • +
  • + Example: +
    T v;
    +optional<T> opt0(v);
    +optional<U> opt1;
    +
    +opt1 = opt0 ;
    +assert ( *opt1 == static_cast<U>(v) ) ;
    +
    +
  • +
+

+ space +

+

+ template<U> optional& + optional<T>::operator= ( optional<U>&& rhs + ) ; +

+
    +
  • +

    + Effect: +

    +
    +++++ + + + + + + + + + + + + + + + + + + +
    + +

    + *this contains a value +

    +
    +

    + *this does not contain a value +

    +
    +

    + rhs + contains a value +

    +
    +

    + assigns std::move(*rhs) to the contained value +

    +
    +

    + initializes the contained value as if direct-initializing + an object of type T + with std::move(*rhs) +

    +
    +

    + rhs + does not contain a value +

    +
    +

    + destroys the contained value by calling val->T::~T() +

    +
    +

    + no effect +

    +
    +
  • +
  • + Returns: *this. +
  • +
  • + Postconditions: bool(rhs) == bool(*this). +
  • +
  • + Exception Safety: If any exception + is thrown, the result of the expression bool(*this) remains unchanged. If an exception + is thrown during the call to T's + constructor, no effect. If an exception is thrown during the call to + T's assignment, the + state of its contained value is as defined by the exception safety + guarantee of T's copy + assignment. +
  • +
  • + Example: +
    T v;
    +optional<T> opt0(v);
    +optional<U> opt1;
    +
    +opt1 = std::move(opt0) ;
    +assert ( opt0 );
    +assert ( opt1 )
    +assert ( *opt1 == static_cast<U>(v) ) ;
    +
    +
  • +
+

+ space +

+

+ template<class... Args> + void optional<T>::emplace( Args...&& args + ); +

+
    +
  • + Requires: The compiler supports rvalue + references and variadic templates. +
  • +
  • + Effect: If *this is initialized calls *this = none. + Then initializes in-place the contained value as if direct-initializing + an object of type T + with std::forward<Args>(args).... +
  • +
  • + Postconditions: *this is initialized. +
  • +
  • + Throws: Whatever the selected T's constructor throws. +
  • +
  • + Exception Safety: If an exception + is thrown during the initialization of T, + *this + is uninitialized. +
  • +
  • + Notes: T + need not be MoveConstructible + or MoveAssignable. + On compilers that do not support variadic templates, the signature + falls back to two overloads:template<class + Arg> + void emplace(Arg&& arg) and void + emplace(). + On compilers that do not support rvalue references, the signature falls + back to three overloads: taking const + and non-const lvalue reference, + and third with empty function argument list. +
  • +
  • + Example: +
    T v;
    +optional<const T> opt;
    +opt.emplace(0);  // create in-place using ctor T(int)
    +opt.emplace();   // destroy previous and default-construct another T
    +opt.emplace(v);  // destroy and copy-construct in-place (no assignment called)
    +
    +
  • +
+

+ space +

+

+ template<InPlaceFactory> + optional<T>& + optional<T>::operator=( InPlaceFactory const& f ); +

+

+ template<TypedInPlaceFactory> + optional<T>& + optional<T>::operator=( TypedInPlaceFactory const& f ); +

+
    +
  • + Effect: Assigns an optional + with a value of T obtained + from the factory. +
  • +
  • + Postconditions: *this is initialized + and its value is directly given from the factory + f (i.e., the value + is not copied). +
  • +
  • + Throws: Whatever the T constructor called by the factory + throws. +
  • +
  • + Notes: See In-Place + Factories +
  • +
  • + Exception Safety: Exceptions can only + be thrown during the call to the T + constructor used by the factory; in that case, the optional + object will be reset to be uninitialized. +
  • +
+

+ space +

+

+ void optional<T>::reset( T const& v ) ; +

+
  • + Deprecated: same as operator= + ( T + const& + v) + ; +
+

+ space +

+

+ void optional<T>::reset() noexcept + ; +

+
  • + Deprecated: Same as operator=( + none_t ); +
+

+ space +

+

+ T const& optional<T>::get() const ; +

+

+ T& + optional<T>::get() ; +

+

+ inline T + const& + get ( + optional<T> const& ) ; +

+

+ inline T& get + ( optional<T> &) + ; +

+
    +
  • + Requires: *this is initialized +
  • +
  • + Returns: A reference to the contained + value +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). +
  • +
+

+ space +

+

+ T const& optional<T>::operator*() const& ; +

+

+ T& + optional<T>::operator*() + &; +

+
    +
  • + Requires: *this is initialized +
  • +
  • + Returns: A reference to the contained + value +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). + On compilers that do not support ref-qualifiers on member functions + these two overloads are replaced with the classical two: a const and non-const + member functions. +
  • +
  • + Example: +
    T v ;
    +optional<T> opt ( v );
    +T const& u = *opt;
    +assert ( u == v ) ;
    +T w ;
    +*opt = w ;
    +assert ( *opt == w ) ;
    +
    +
  • +
+

+ space +

+

+ T&& + optional<T>::operator*() + &&; +

+
    +
  • + Requires: *this contains a value. +
  • +
  • + Effects: Equivalent to return std::move(*val);. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). + On compilers that do not support ref-qualifiers on member functions + this overload is not present. +
  • +
+

+ space +

+

+ T const& optional<T>::value() const& ; +

+

+ T& + optional<T>::value() & ; +

+
    +
  • + Effects: Equivalent to return bool(*this) ? *val : throw bad_optional_access();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions these two overloads are replaced + with the classical two: a const + and non-const member functions. +
  • +
  • + Example: +
    T v ;
    +optional<T> o0, o1 ( v );
    +assert ( o1.value() == v );
    +
    +try {
    +  o0.value(); // throws
    +  assert ( false );
    +}
    +catch(bad_optional_access&) {
    +  assert ( true );
    +}
    +
    +
  • +
+

+ space +

+

+ T&& + optional<T>::value() && ; +

+
    +
  • + Effects: Equivalent to return bool(*this) ? std::move(*val) : throw bad_optional_access();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is not present. +
  • +
+

+ space +

+

+ template<class U> T optional<T>::value_or(U && + v) + const& + ; +

+
    +
  • + Effects: Equivalent to if (*this) return **this; else return + std::forward<U>(v);. +
  • +
  • + Remarks: If T + is not CopyConstructible or U && + is not convertible to T, + the program is ill-formed. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is replaced with the + const-qualified member + function. On compilers without rvalue reference support the type of + v becomes U const&. +
  • +
+

+ space +

+

+ template<class U> T optional<T>::value_or(U && + v) + && ; +

+
    +
  • + Effects: Equivalent to if (*this) return std::move(**this); else return std::forward<U>(v);. +
  • +
  • + Remarks: If T + is not MoveConstructible + or U && + is not convertible to T, + the program is ill-formed. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is not present. +
  • +
+

+ space +

+

+ template<class F> T optional<T>::value_or_eval(F f) const& ; +

+
    +
  • + Requires: T + is CopyConstructible and F models a Generator whose result type + is convertible to T. +
  • +
  • + Effects: if + (*this) return **this; else return f();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is replaced with the + const-qualified member + function. +
  • +
  • + Example: +
    int complain_and_0()
    +{
    +  clog << "no value returned, using default" << endl;
    +  return 0;
    +}
    +
    +optional<int> o1 = 1;
    +optional<int> oN = none;
    +
    +int i = o1.value_or_eval(complain_and_0); // fun not called
    +assert (i == 1);
    +
    +int j = oN.value_or_eval(complain_and_0); // fun called
    +assert (i == 0);
    +
    +
  • +
+

+ space +

+

+ template<class F> T optional<T>::value_or_eval(F f) && + ; +

+
    +
  • + Requires: T + is MoveConstructible + and F models a Generator + whose result type is convertible to T. +
  • +
  • + Effects: if + (*this) return std::move(**this); else return + f();. +
  • +
  • + Notes: On compilers that do not support + ref-qualifiers on member functions this overload is not present. +
  • +
+

+ space +

+

+ T const& optional<T>::get_value_or( T const& default) const ; +

+

+ T& + optional<T>::get_value_or( + T& + default ) + ; +

+
    +
  • + Deprecated: Use value_or() instead. +
  • +
  • + Returns: A reference to the contained + value, if any, or default. +
  • +
  • + Throws: Nothing. +
  • +
  • + Example: +
    T v, z ;
    +optional<T> def;
    +T const& y = def.get_value_or(z);
    +assert ( y == z ) ;
    +
    +optional<T> opt ( v );
    +T const& u = opt.get_value_or(z);
    +assert ( u == v ) ;
    +assert ( u != z ) ;
    +
    +
  • +
+

+ space +

+

+ T const* optional<T>::get_ptr() const ; +

+

+ T* + optional<T>::get_ptr() + ; +

+
    +
  • + Returns: If *this is initialized, a pointer to the + contained value; else 0 + (null). +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The contained value is permanently + stored within *this, + so you should not hold nor delete this pointer +
  • +
  • + Example: +
    T v;
    +optional<T> opt(v);
    +optional<T> const copt(v);
    +T* p = opt.get_ptr() ;
    +T const* cp = copt.get_ptr();
    +assert ( p == get_pointer(opt) );
    +assert ( cp == get_pointer(copt) ) ;
    +
    +
  • +
+

+ space +

+

+ T const* optional<T>::operator + ->() const + ; +

+

+ T* + optional<T>::operator ->() + ; +

+
    +
  • + Requires: *this is initialized. +
  • +
  • + Returns: A pointer to the contained + value. +
  • +
  • + Throws: Nothing. +
  • +
  • + Notes: The requirement is asserted + via BOOST_ASSERT(). +
  • +
  • + Example: +
    struct X { int mdata ; } ;
    +X x ;
    +optional<X> opt (x);
    +opt->mdata = 2 ;
    +
    +
  • +
+

+ space +

+

+ explicit optional<T>::operator + bool() + const noexcept + ; +

+
    +
  • + Returns: get_ptr() != 0. +
  • +
  • + Notes: On compilers that do not support + explicit conversion operators this falls back to safe-bool idiom. +
  • +
  • + Example: +
    optional<T> def ;
    +assert ( def == 0 );
    +optional<T> opt ( v ) ;
    +assert ( opt );
    +assert ( opt != 0 );
    +
    +
  • +
+

+ space +

+

+ bool optional<T>::operator!() noexcept + ; +

+
    +
  • + Returns: If *this is uninitialized, true; else false. +
  • +
  • + Notes: This operator is provided for + those compilers which can't use the unspecified-bool-type + operator in certain boolean contexts. +
  • +
  • + Example: +
    optional<T> opt ;
    +assert ( !opt );
    +*opt = some_T ;
    +
    +// Notice the "double-bang" idiom here.
    +assert ( !!opt ) ;
    +
    +
  • +
+

+ space +

+

+ bool optional<T>::is_initialized() const ; +

+
  • + Deprecated: Same as explicit operator + bool () + ; +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header__boost_optional_hpp_.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header__boost_optional_hpp_.html new file mode 100644 index 0000000..8496d37 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header__boost_optional_hpp_.html @@ -0,0 +1,47 @@ + + + +Header <boost/optional.hpp> + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +

+ This is an alias for header <boost/optional/optional.hpp>. +

+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html new file mode 100644 index 0000000..c3325c5 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_refs.html @@ -0,0 +1,113 @@ + + + +Optional References + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
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* pointer_type;
+    typedef T* pointer_const_type;   // no const propagation
+
+    optional () noexcept ; R
+
+    optional ( none_t ) noexcept ; R
+
+    template<class R> optional(R&& r) noexcept ;  R
+
+    template <class R> optional(bool cond, R&& r) noexcept ; R
+
+    optional ( optional const& rhs ) noexcept ; R
+
+    template<class U> explicit optional ( optional<U&> const& rhs ) noexcept ; R
+
+    optional& operator = ( none_t ) noexcept ; R
+
+
+    optional& operator = ( optional const& rhs ) noexcept; R
+
+    template<class U> optional& operator = ( optional<U&> const& rhs ) noexcept ; R
+
+    template<class R> optional& operator = (R&& r) noexcept ; R
+
+    template<class R> void emplace ( R&& r ) noexcept ; R
+
+    T& get() const ; R
+    T& operator *() const ; R
+
+    T* operator ->() const ; R
+
+    T& value() const& ; R
+
+    template<class R> T& value_or( R && r ) const noexcept ; R
+
+    template<class F> T& value_or_eval( F f ) const ; R
+
+    T* get_ptr() const noexcept ; R
+
+    explicit operator bool() const noexcept ; R
+
+    bool operator!() const noexcept ; R
+
+    // deprecated methods
+
+    // (deprecated)
+    void reset() noexcept ; R
+
+    // (deprecated)
+    template<class R> void reset ( R && r ) noexcept ; R
+
+    // (deprecated)
+    bool is_initialized() const noexcept ; R
+
+    // (deprecated)
+    template<class R> T& get_value_or( R && r ) constnoexcept; R
+
+private:
+    T* ref; // exposition only
+};
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html new file mode 100644 index 0000000..2877563 --- /dev/null +++ b/doc/html/boost_optional/reference/header__boost_optional_optional_hpp_/header_optional_optional_values.html @@ -0,0 +1,140 @@ + + + +Optional Values + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
template <class T>
+class optional
+{
+public :
+
+    typedef T         value_type ;
+    typedef T &       reference_type ;
+    typedef T const&  reference_const_type ;
+    typedef T *       pointer_type ;
+    typedef T const*  pointer_const_type ;
+
+    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
+
+    template<class F> T value_or_eval( F f ) const& ; R
+    template<class F> T value_or_eval( F f ) && ; R
+
+    T const* get_ptr() const ; R
+    T*       get_ptr() ; R
+
+    explicit operator bool() const noexcept ; 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
+};
+
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/boost_optional/reference/relnotes.html b/doc/html/boost_optional/reference/relnotes.html new file mode 100644 index 0000000..c67535e --- /dev/null +++ b/doc/html/boost_optional/reference/relnotes.html @@ -0,0 +1,183 @@ + + + +Release Notes + + + + + + + + + + + + + + + +
Boost C++ LibrariesHomeLibrariesPeopleFAQMore
+
+
+PrevUpHomeNext +
+
+ +
+ + Boost Release + X.XX +
+
  • + Now boost::optional is specialized for reference + parameters. This way the sizeof + of optional reference is that of a pointer, and a number of bugs is avoided. +
+
+ + Boost Release + 1.60 +
+
  • + Changed the implementation of boost::none + again. Now it is a const object with internal linkage (as any other tag). + This fixes Trac + #11203. +
+
+ + Boost Release + 1.59 +
+
    +
  • + For C++03 compilers, added 0-argument overload for member function emplace(), + and therewith removed the dependency on <boost/utility/in_place_factory.hpp>. +
  • +
  • + Fixed Trac + #11241. +
  • +
+
+ + Boost Release + 1.58 +
+
    +
  • + boost::none_t is no longer convertible from + literal 0. This avoids a + bug where optional<rational<int>> + oi = + 0; + would initialize an optional object with no contained value. +
  • +
  • + Improved the trick that prevents streaming out optional + without header optional_io.hpp + by using safe-bool idiom. This addresses Trac + #10825. +
  • +
  • + IOStream operators are now mentioned in documentation. +
  • +
  • + Added a way to manually disable move semantics: just define macro BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES. + This can be used to work around Trac + #10399. +
  • +
  • + It is no longer possible to assign optional<U> to optional<T> when U + is not assignable or convertible to T + (Trac #11087). +
  • +
  • + Value accessors now work correctly on rvalues of optional<T&> (Trac + #10839). +
  • +
+
+ + Boost Release + 1.57 +
+
  • + Git pull #9: + "Supply <string> + to fix C++03 compile error on logic_error("...")". +
+
+ + Boost Release + 1.56 +
+
    +
  • + Added support for rvalue references. Now optional<T> works with moveable but non-copyable + T's, +
  • +
  • + Improved swap (now uses + move operations), +
  • +
  • + Added function emplace(). This is the last of the requests from + Trac #1841, +
  • +
  • + optional is moveable, + including conditional noexcept + specifications, which make it move_if_noexcept-friendly, +
  • +
  • + Using explicit operator bool() on platforms that support it (Trac + #4227) (breaking change), +
  • +
  • + Forward declaration of operator<<(ostream&, optional + const&) + to prevent inadvertent incorrect serialization of optional objects, +
  • +
  • + Removed deprecated function reset() from examples (Trac + #9005), +
  • +
  • + Equality comparison with boost::none + does not require that T + be EqualityComparable, +
  • +
  • + Optional rvalue references are explicitly disallowed, +
  • +
  • + Binding temporaries to optional references is explicitly disallowed (breaking + change), +
  • +
  • + More ways to access the contained value, functions value(), value_or(), value_or_eval(), +
  • +
  • + Updated and reorganized documentation, added tutorial and quick guide + sections. +
  • +
+
+ + + +
+
+
+PrevUpHomeNext +
+ + diff --git a/doc/html/index.html b/doc/html/index.html index b138f4f..2cdf6cd 100644 --- a/doc/html/index.html +++ b/doc/html/index.html @@ -146,7 +146,7 @@
- +

Last revised: February 13, 2016 at 13:50:14 GMT

Last revised: February 16, 2016 at 20:02:53 GMT


diff --git a/doc/html/optional/reference/header__boost_optional_optional_hpp_.html b/doc/html/optional/reference/header__boost_optional_optional_hpp_.html index f8905f5..a395d63 100644 --- a/doc/html/optional/reference/header__boost_optional_optional_hpp_.html +++ b/doc/html/optional/reference/header__boost_optional_optional_hpp_.html @@ -7,7 +7,7 @@ - + @@ -20,7 +20,7 @@

-PrevUpHomeNext +PrevUpHomeNext

@@ -36,134 +36,50 @@ namespace boost { template <class T> -class optional -{ -public : +class optional ; R - typedef T value_type; +template <class T> +class optional<T&> ; R - // (If T is of reference type, the parameters and results by reference are by value) +template<class T> inline bool operator == ( optional<T> const& x, optional<T> const& y ) ; R - optional () noexcept ; R +template<class T> inline bool operator != ( optional<T> const& x, optional<T> const& y ) ; R - optional ( none_t ) noexcept ; R +template<class T> inline bool operator < ( optional<T> const& x, optional<T> const& y ) ; R - optional ( T const& v ) ; R +template<class T> inline bool operator > ( optional<T> const& x, optional<T> const& y ) ; R - optional ( T&& v ) ; R +template<class T> inline bool operator <= ( optional<T> const& x, optional<T> const& y ) ; R - // [new in 1.34] - optional ( bool condition, T const& v ) ; R +template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; R - optional ( optional const& rhs ) ; R +template<class T> inline bool operator == ( optional<T> const& x, none_t ) noexcept ; R - optional ( optional&& rhs ) noexcept(see below) ; R +template<class T> inline bool operator != ( optional<T> const& x, none_t ) noexcept ; R - template<class U> explicit optional ( optional<U> const& rhs ) ; R +template<class T> inline optional<T> make_optional ( T const& v ) ; R - template<class U> explicit optional ( optional<U>&& rhs ) ; R +template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; R - template<class InPlaceFactory> explicit optional ( InPlaceFactory const& f ) ; R +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; R - template<class TypedInPlaceFactory> explicit optional ( TypedInPlaceFactory const& f ) ; R +template<class T> inline auto get_optional_value_or ( optional<T> const& opt, typename optional<T>::reference_type def ) -> typename optional<T>::reference_type ; R - optional& operator = ( none_t ) noexcept ; R +template<class T> inline T const& get ( optional<T> const& opt ) ; R - optional& operator = ( T const& v ) ; R +template<class T> inline T& get ( optional<T> & opt ) ; R - optional& operator = ( T&& v ) ; R +template<class T> inline T const* get ( optional<T> const* opt ) ; R - optional& operator = ( optional const& rhs ) ; R +template<class T> inline T* get ( optional<T>* opt ) ; R - optional& operator = ( optional&& rhs ) noexcept(see below) ; R +template<class T> inline auto get_pointer ( optional<T> const& opt ) -> see below; R - template<class U> optional& operator = ( optional<U> const& rhs ) ; R +template<class T> inline auto get_pointer ( optional<T> & opt ) -> see below; R - template<class U> optional& operator = ( optional<U>&& rhs ) ; R +template<class T> inline void swap( optional<T>& x, optional<T>& y ) ; 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 - - template<class F> T value_or_eval( F f ) const& ; R - template<class F> T value_or_eval( F f ) && ; R - - T const* get_ptr() const ; R - T* get_ptr() ; R - - explicit operator bool() const noexcept ; 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 +template<class T> inline void swap( optional<T&>& x, optional<T&>& y ) ; R } // namespace boost @@ -179,7 +95,7 @@
-PrevUpHomeNext +PrevUpHomeNext