diff --git a/doc/optional.html b/doc/optional.html index 895312d..61a29c5 100644 --- a/doc/optional.html +++ b/doc/optional.html @@ -3,7 +3,6 @@
- @@ -324,6 +323,8 @@ class optional optional ( T const& v ) ; + optional ( bool condition, T const& v ) ; [new in 1.34] + optional ( optional const& rhs ) ; template<class U> explicit optional ( optional<U> const& rhs ) ; @@ -347,6 +348,8 @@ class optional T const& get() const ; T& get() ; + T const& get_value_or( T const& default ) const ; [new in 1.34] + T const* operator ->() const ; T* operator ->() ; @@ -380,6 +383,12 @@ template<class T> inline bool operator <= ( optional<T> const& x, op template<class T> inline bool operator >= ( optional<T> const& x, optional<T> const& y ) ; +template<class T> inline optional<T> make_optional ( T const& v ) ; [new in 1.34] + +template<class T> inline optional<T> make_optional ( bool condition, T const& v ) ; [new in 1.34] + +template<class T> inline T const& get_optional_value_or ( optional<T> const& opt, T const& default ) ; [new in 1.34] + template<class T> inline T const& get ( optional<T> const& opt ) ; template<class T> inline T& get ( optional<T> & opt ) ; @@ -436,7 +445,7 @@ assert ( !def ) ;optional<T>::optional( none_t );
-Effect: Constructs an optional uninitialized.
+Effect: Constructs an optional uninitialized.
Postconditions: *this is uninitialized.
Throws: Nothing.
Notes:
@@ -459,7 +468,6 @@ assert ( !n ) ;optional<T (not a ref)>::optional( T const& v )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.
@@ -495,6 +503,23 @@ assert (*opt == v);
+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() +
+
+optional<T (not a ref)>::optional( optional const& rhs );Effect: Copy-Constructs an optional.
@@ -797,7 +822,6 @@ assert ( *opt1 == static_cast<U>(v) ) ;
-T const& optional<T (not a ref)>::operator*() const ; T& optional<T (not a ref)>::operator*();@@ -828,6 +852,32 @@ assert ( *opt == w ) ;
+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 ) ; ++++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 ) ; ++
+T const& optional<T&>::operator*() const ; T & optional<T&>::operator*();@@ -965,18 +1015,47 @@ assert ( opt.is_initialized() );
+optional<T (not a ref)> make_optional( T const& v )+++Returns: optional<T>(v) for the deduced type
+T
ofv
.Example:
+++template<class T> void foo ( optional<T> const& opt ) ; + +foo ( make_optional(1+1) ) ; // Creates an optional<int> +
+ +optional<T (not a ref)> make_optional( bool condition, T const& v )+++ +Returns: optional<T>(condition,v) for the deduced type
+T
ofv
.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"); +
+bool operator == ( optional<T> const& x, optional<T> const& y );Returns: If both x and y are initialied,
+If only x or y is initialized,(*x == *y)
. -If only x or y is initialized,false
. If both are uninitialized,true
. -false
. If both are uninitialized,true
.Throws: Nothing.
Notes: 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 -
+use equal_pointees() insteadExample:
T x(12); @@ -1012,14 +1091,12 @@ assert ( optX != optZ ) ;Returns: If y is not initialized,
+If both x and y are initialized,false
. If y is initialized and x is not initialized,true
. -If both x and y are initialized,(*x < *y)
. -(*x < *y)
.Throws: Nothing.
Notes: 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 -
+use less_pointees() insteadExample:
T x(12); @@ -1082,23 +1159,17 @@ assert ( optX != optZ ) ;-void swap ( optional<T>& x, optional<T>& y );-Effect: If both x and y are initialized, calls
swap(*x,*y)
-using std::swap.
+Effect: If both x and y are initialized, calls
+If none is initialized, does nothing.swap(*x,*y)
using std::swap.
If only one is initialized, say x, calls:y.reset(*x); x.reset();
-If none is initialized, does nothing. -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 const& ) throws. -
-Notes: If both are initialized, swap(T&,T&) is used unqualified -but with std::swap introduced in scope.
+If only one is initialized, whatever T::T ( T const& ) throws. +
-If only one is initialized, T::~T() and T::T( T const& ) is called. -Notes: If both are initialized, swap(T&,T&) is used unqualified but with std::swap introduced in scope.
+If only one is initialized, T::~T() and T::T( T const& ) is called.Exception Safety: If both are initialized, this operation has the exception safety guarantees of swap(T&,T&).
+If only one is initialized, it has the same basic guarantee as optional<T>::reset( T const& ).
-If only one is initialized, it has the same basic guarantee as optional<T>::reset( T const& ). -Example:
T x(12); @@ -1254,8 +1325,7 @@ assert(a==b); b = 3 ; assert(ra!=b); // 'ra' is not rebound to 'b'-Now, if you assign to an initialized optional<T&>, the effect is to -rebind to the new object instead of assigning the referee. This is unlike +
Now, if you assign to an initialized optional<T&>, the effect is to rebind to the new object instead of assigning the referee. This is unlike bare C++ references.
int a = 1 ; int b = 2 ; @@ -1358,8 +1428,7 @@ public:A limitation of this method is that it doesn't scale well to wrapped objects with multiple constructors nor to generic code were the constructor overloads are unknown.
-The solution presented in this library is the family of InPlaceFactories and -TypedInPlaceFactories.
+The solution presented in this library is the family of InPlaceFactories and TypedInPlaceFactories.
@@ -1427,10 +1496,7 @@ public: W ( in_place(123,"hello") ) ; }
These factories are a family of classes which encapsulate an increasing number of arbitrary constructor parameters and supply a method to construct an object of a given type using those parameters at an address specified by the user via placement new.The factories are implemented in the headers: -in_place_factory.hpp and -typed_in_place_factory.hpp -
+The factories are implemented in the headers: in_place_factory.hpp and typed_in_place_factory.hpp
@@ -1473,8 +1539,7 @@ of the assignment methods: TypedInPlaceFactory const& )- optional<T>:::reset ( T const&)
Can only guarantee the basic exception safety: The lvalue optional is left uninitialized -if an exception is thrown (any previous value is first destroyed using T::~T())
+Can only guarantee the basic exception safety: The lvalue optional is left uninitialized if an exception is thrown (any previous value is first destroyed using T::~T())
On the other hand, the uninitializing methods:
- @@ -1603,12 +1668,9 @@ T is not required to be -LICENSE_1_0.txt or copy at -www.boost.org/LICENSE_1_0.txt) +License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at www.boost.org/LICENSE_1_0.txt)
optional<T>::operator= ( detail::none_t )
Developed by Fernando Cacciola, the latest version of this file can be found at www.boost.org, and the boost -discussion lists
- +HREF="http://www.boost.org">www.boost.org, and the boost discussion lists +