2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[/
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Boost.Optional
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Copyright (c) 2003-2007 Fernando Luis Cacciola Carballal
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    Distributed under the Boost Software License, Version 1.0.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    (See accompanying file LICENSE_1_0.txt or copy at
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								    http://www.boost.org/LICENSE_1_0.txt)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[section Detailed Semantics - Optional Values]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional() noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effect:] Default-Constructs an `optional`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `*this` is [_uninitialized].
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] T's default constructor [_is not] called.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> def ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !def ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_none_t]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( none_t ) noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( T const& v )`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `is_copy_constructible<T>::value` is `true`.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Effect:] Directly-Constructs an `optional`.
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `*this` is [_initialized] and its value is a ['copy]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								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 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_move_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( T&& v )`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_bool_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( bool condition, T const& v ) ;` ]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* If condition is true, same as:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( T const& v )`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* otherwise, same as:
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional()`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( optional const& rhs );`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `is_copy_constructible<T>::value` is `true`.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_move_constructor_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T>::optional( optional&& rhs ) noexcept(`['see below]`);`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 11:38:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Notes:] If `rhs` is initialized, `T::T( T && )` is called.
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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 );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:39 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								optional<std::unique_ptr<T>> init( std::unique_ptr<T>(new T(2)) );
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_other_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<U> explicit optional<T>::optional( optional<U> const& rhs );`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_move_constructor_other_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<U> explicit optional<T>::optional( optional<U>&& rhs );`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effect:] Move-constructs an `optional`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] If `rhs` is initialized, `*this` is initialized and its
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								value is move-constructed from `*rhs`; else `*this` is
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-10-28 00:01:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_in_place_init]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class... Args> explicit optional<T>::optional( in_place_init_t, Args&&... ars );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] `is_constructible_v<T, Args&&...>` is `true`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effect:] Initializes the contained value as if direct-non-list-initializing an object of type `T` with the
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								arguments `std::forward<Args>(args)...`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `*this` is initialized.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Throws:] Any exception thrown by the selected constructor of `T`.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:37 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not support variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
							 
						 
					
						
							
								
									
										
										
										
											2016-10-28 00:01:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// creates an std::mutex using its default constructor
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<std::mutex> om {in_place_init};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (om);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// creates a unique_lock by calling unique_lock(*om, std::defer_lock)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<std::unique_lock<std::mutex>> ol {in_place_init, *om, std::defer_lock};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (ol);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (!ol->owns_lock());
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_in_place_init_if]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class... Args> explicit optional<T>::optional( in_place_init_if_t, bool condition, Args&&... ars );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] `is_constructible_v<T, Args&&...>` is `true`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effect:] If `condition` is `true`, initializes the contained value as if direct-non-list-initializing an object of type `T` with the arguments `std::forward<Args>(args)...`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(*this) == condition`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Throws:] Any exception thrown by the selected constructor of `T`.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:37 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes: ] `T` need not be __MOVE_CONSTRUCTIBLE__. On compilers that do not support variadic templates or rvalue references, this constuctor is available in limited functionality. For details [link optional_emplace_workaround see here].
							 
						 
					
						
							
								
									
										
										
										
											2016-10-28 00:01:13 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<std::vector<std::string>> ov1 {in_place_init_if, false, 3, "A"};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (!ov1);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<std::vector<std::string>> ov2 {in_place_init_if, true, 3, "A"};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (ov2);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (ov2->size() == 3);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_constructor_factory]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<InPlaceFactory> explicit optional<T>::optional( InPlaceFactory const& f );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<TypedInPlaceFactory> explicit optional<T>::optional( TypedInPlaceFactory const& f );`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] See [link boost_optional.tutorial.in_place_factories In-Place Factories]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-07 17:07:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_equal_none_t]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional& optional<T>::operator= ( none_t ) noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effect:] If `*this` is initialized destroys its contained value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions: ] `*this` is uninitialized.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_equal_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional& optional<T>::operator= ( T const& rhs ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_move_equal_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional& optional<T>::operator= ( T&& rhs ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_equal_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional& optional<T>::operator= ( optional const& rhs ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 22:30:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `CopyAssignable`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:]
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[table
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  []
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  [[][[*`*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]]
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 22:30:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns:] `*this`;
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(rhs) == bool(*this)`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 22:30:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T v;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> opt(v);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> def ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								opt = def ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !def ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								// previous value (copy of 'v') destroyed from within 'opt'.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_move_equal_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional& optional<T>::operator= ( optional&& rhs ) noexcept(`['see below]`);`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `MoveAssignable`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:]
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[table
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [[][[*`*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]]
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 22:30:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns:] `*this`;
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(rhs) == bool(*this)`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 11:38:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Remarks:] The expression inside `noexcept` is equivalent to `is_nothrow_move_constructible<T>::value && is_nothrow_move_assignable<T>::value`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 22:30:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Exception Safety:] If any exception is thrown, the initialization state of `*this` and `rhs` remains unchanged. If an exception is
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								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.
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> opt(T(2)) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> def ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								opt = def ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( def ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( opt ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( *opt == T(2) ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_equal_other_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<U> optional& optional<T>::operator= ( optional<U> const& rhs ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effect:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[table
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [[][[*`*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]]
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `*this`.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(rhs) == bool(*this)`.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T v;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> opt0(v);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<U> opt1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								opt1 = opt0 ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( *opt1 == static_cast<U>(v) ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_move_equal_other_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<U> optional& optional<T>::operator= ( optional<U>&& rhs ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effect:]
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[table
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  []
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  [[][[*`*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]]
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `*this`.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(rhs) == bool(*this)`.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T v;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> opt0(v);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<U> opt1;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								opt1 = std::move(opt0) ;
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( opt0 );
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( opt1 )
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( *opt1 == static_cast<U>(v) ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-03 17:36:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_emplace]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-09 18:33:23 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<class... Args> void optional<T>::emplace( Args&&... args );`]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-03 17:36:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								 of type `T` with `std::forward<Args>(args)...`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-03 17:36:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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].
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:37 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] `T` need not be __MOVE_CONSTRUCTIBLE__ or `MoveAssignable`. On compilers that do not support variadic templates or rvalue references, this function is available in limited functionality. For details [link optional_emplace_workaround see here].
							 
						 
					
						
							
								
									
										
										
										
											2014-06-06 23:24:43 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
									
										
										
										
											2014-06-03 17:36:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_equal_factory]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<InPlaceFactory> optional<T>& optional<T>::operator=( InPlaceFactory const& f );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<TypedInPlaceFactory> optional<T>& optional<T>::operator=( TypedInPlaceFactory const& f );`]
							 
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] See [link boost_optional.tutorial.in_place_factories In-Place Factories]
							 
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Exception Safety:] Exceptions can only be thrown during the call to
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								the `T` constructor used by the factory; in that case, the `optional` object
							 
						 
					
						
							
								
									
										
										
										
											2011-04-06 21:56:23 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								will be reset to be ['uninitialized].
							 
						 
					
						
							
								
									
										
										
										
											2011-04-06 20:54:18 +00:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_reset_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `void optional<T>::reset( T const& v ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Deprecated:] same as `operator= ( T const& v) ;`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_reset]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-07 17:07:12 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `void optional<T>::reset() noexcept ;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-10-23 02:20:23 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Same as `operator=( none_t );`
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_get]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T const& optional<T>::get() const ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T&       optional<T>::get() ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `inline T const& get ( optional<T> const& ) ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `inline T&       get ( optional<T> &) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `*this` is initialized
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] A reference to the contained value
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Throws:] Nothing.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_asterisk]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T const& optional<T>::operator*() const& ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T&       optional<T>::operator*() &;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] `*this` is initialized
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] A reference to the contained value
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Throws:] Nothing.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T v ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> opt ( v );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T const& u = *opt;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( u == v ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T w ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								*opt = w ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( *opt == w ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_asterisk_move]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T&& optional<T>::operator*() &&;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-28 00:31:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `*this` contains a value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `return std::move(*val);`.
							 
						 
					
						
							
								
									
										
										
										
											2014-07-10 13:49:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] The requirement is asserted via `BOOST_ASSERT()`. On compilers that do not support ref-qualifiers on member functions this overload is not present.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 23:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T const& optional<T>::value() const& ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T&       optional<T>::value() & ;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 23:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-28 00:31:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 23:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T v ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> o0, o1 ( v );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( o1.value() == v );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								try {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  o0.value(); // throws
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  assert ( false );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								catch(bad_optional_access&) {
							 
						 
					
						
							
								
									
										
										
										
											2014-06-03 17:36:18 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  assert ( true );
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 23:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								}
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_value_move]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-07-10 13:49:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T&& optional<T>::value() && ;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-28 00:31:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `return bool(*this) ? std::move(*val) : throw bad_optional_access();`.
							 
						 
					
						
							
								
									
										
										
										
											2014-07-10 13:49:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is not present.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-23 16:38:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_value_or]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-04 18:13:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<class U> T optional<T>::value_or(U && v) const& ;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-05-23 16:38:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-28 00:31:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `if (*this) return **this; else return std::forward<U>(v);`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Remarks:] If `T` is not __COPY_CONSTRUCTIBLE__ or `U &&` is not convertible to `T`, the program is ill-formed.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-16 14:23:34 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_value_or_move]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class U> T optional<T>::value_or(U && v) && ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-28 00:31:36 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `if (*this) return std::move(**this); else return std::forward<U>(v);`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Remarks:] If `T` is not __MOVE_CONSTRUCTIBLE__ or `U &&` is not convertible to `T`, the program is ill-formed.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] On compilers that do not support ref-qualifiers on member functions this overload is not present.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_value_or_call]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> T optional<T>::value_or_eval(F f) const& ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] `T` is __COPY_CONSTRUCTIBLE__ and `F` models a __SGI_GENERATOR__ whose result type is convertible to `T`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 11:38:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-18 15:01:52 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_value_or_call_move]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> T optional<T>::value_or_eval(F f) && ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] `T` is __MOVE_CONSTRUCTIBLE__ and `F` models a __SGI_GENERATOR__ whose result type is convertible to `T`.
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 11:38:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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.
							 
						 
					
						
							
								
									
										
										
										
											2014-05-22 23:32:49 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 18:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_map]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 20:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T>::map(F f) const& -> `['see below]` ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T>::map(F f) & -> `['see below]` ;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 18:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] `if (*this) return f(**this); else return none;`
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] The return type of these overloads is `optional<decltype(f(**this))>`. On compilers that do not support ref-qualifiers on member functions, these two (as well as the next one) overloads are replaced with good old const and non-const overloads.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								auto length = [](const string& s){ return s.size(); };
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<string> o1 {}, o2 {"cat"};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<size_t> os1 = o1.map(length), os2 = o2.map(length);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !os1 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( os2 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( *os2 == 3 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 18:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_map_move]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 20:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T>::map(F f) && -> `['see below]` ;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 18:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] `if (*this) return f(std::move(**this)); else return none;`
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 20:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] The return type of this overload is `optional<decltype(f(istd::move(**this)))>`.
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 18:27:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_flat_map]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T>::flat_map(F f) const& -> `['see below]` ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T>::flat_map(F f) & -> `['see below]` ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] The return type of expression `f(**this)` is `optional<U>` for some object or reference type `U`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] `if (*this) return f(**this); else return none;`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Notes:] The return type of these overloads is `optional<U>`. On compilers that do not support ref-qualifiers on member functions, these two (as well as the next one) overloads are replaced with good old const and non-const overloads.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<char> first_char(const string& s) {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  return s.empty() ? none : optional<char>(s[0]);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<string> o1 {}, o2 {"cat"};
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<char> os1 = o1.flat_map(first_char), os2 = o2.flat_map(first_char);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !os1 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( os2 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( *os2 == 'c' ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_flat_map_move]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T>::flat_map(F f) && -> `['see below]` ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] The return type of expression `f(std::move(**this))` is `optional<U>` for some object or reference type `U`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] `if (*this) return f(std::move(**this)); else return none;`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Notes:] The return type of this overload is `optional<U>`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_get_value_or_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T const& optional<T>::get_value_or( T const& default) const ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T&       optional<T>::get_value_or( T&       default ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-23 16:38:42 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Deprecated:] Use `value_or()` instead.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*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 );
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								T const& u = opt.get_value_or(z);
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								assert ( u == v ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( u != z ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_get_ptr]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T const* optional<T>::get_ptr() const ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T*       optional<T>::get_ptr() ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_arrow]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `T const* optional<T>::operator ->() const ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T*       optional<T>::operator ->()       ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires: ] `*this` is initialized.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_bool]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-14 00:46:24 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `explicit optional<T>::operator bool() const noexcept ;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-03-24 00:04:15 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `bool optional<T>::has_value() const noexcept ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-24 10:00:43 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns:] `get_ptr() != 0`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Notes:] On compilers that do not support explicit conversion operators this falls back to safe-bool idiom.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> def ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( def == 0 );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> opt ( v ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( opt );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( opt != 0 );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_operator_not]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `bool optional<T>::operator!() noexcept ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_is_initialized]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool optional<T>::is_initialized() const ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-05-08 21:50:41 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Deprecated:] Same as `explicit operator bool () ;`
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[endsect]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[section Detailed Semantics - Optional References]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_default_ctor]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<T&>::optional() noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<T&>::optional(none_t) noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(*this) == false`; `*this` refers to nothing.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_value_ctor]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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`.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:37 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] This constructor is declared `explicit` on compilers that do not correctly support binding to const lvalues of integral types. For more details [link optional_reference_binding see here].
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T v;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								T& vref = v ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T&> opt(vref);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( *opt == v ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								++ v ; // mutate referee
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert (*opt == v);
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_cond_value_ctor]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_copy_ctor]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<T&>::optional ( optional const& rhs ) noexcept ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects: ] Initializes `ref` with expression `rhs.ref`.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_ctor_from_opt_U]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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`.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(*this) == bool(rhs)`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_assign_none_t]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<T&>::operator= ( none_t ) noexcept ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects: ] Assigns `ref` with expression `nullptr`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*returns:] `*this`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(*this) == false`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_copy_assign]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional& optional<T&>::operator= ( optional const& rhs ) noexcept ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects: ] Assigns `ref` with expression `rhs.ref`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*returns:] `*this`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `bool(*this) == bool(rhs)`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-18 23:18:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] This behaviour is called ['rebinding semantics]. See [link boost_optional.tutorial.optional_references.rebinding_semantics_for_assignment_of_optional_references here] for details.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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 ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_assign_optional_U]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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)`.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_assign_R]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class R> optional& optional<T&>::operator= ( R&& r ) noexcept ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects: ] Assigns `ref` with expression `r`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*returns:] `*this`.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_emplace_R]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_get]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_arrow]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T* optional<T&>::operator -> () const ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] `bool(*this) == true`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects: ] Returns `ref`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Throws: ] Nothing.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T& optional<T&>::value() const ;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `return bool(*this) ? *val : throw bad_optional_access();`.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_value_or]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class R> T& optional<T&>::value_or( R&& r ) const noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `if (*this) return **this; else return r;`.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Remarks:] Unless `R` is an lvalue reference, the program is ill-formed.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_value_or_eval]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-06-23 20:53:16 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_map]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T&>::map( F f ) const -> `['see below]`;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `if (*this) return f(**this); else return none;`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Remarks:] The return type of this function is `optional<decltype(f(**this))>`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_flat_map]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class F> auto optional<T&>::flat_map( F f ) const -> `['see below]`;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Requires:] The return type of expression `f(**this)` is `optional<U>` for some object or reference type `U`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `if (*this) return f(**this); else return none;`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Remarks:] The return type of this function is `optional<U>`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_get_ptr]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `T* optional<T&>::get_ptr () const noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `ref`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_operator_bool]
							 
						 
					
						
							
								
									
										
										
										
											2018-03-24 00:04:15 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `bool has_value() const noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T&>::operator bool () const noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `bool(ref)`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_operator_not]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<T&>::operator ! () const noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `!bool(ref)`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_reset]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `void optional<T&>::reset() noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-10-23 02:20:23 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Same as `*this = none`.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_reset_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class R> void optional<T&>::reset ( R&& r) noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `*this = std::forward<R>(r)`.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Remarks:] This function is deprecated.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_is_initialized]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool optional<T&>::is_initialized() const noexcept;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `return bool(*this)`.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Remarks:] This function is deprecated.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_optional_ref_get_value_or_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `template<class R> T& optional<T&>::get_value_or( R&& r ) const noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Effects:] Equivalent to `return value_or(std::forward<R>(r);`.
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:26 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Remarks:] This function is deprecated.
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[endsect]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[section Detailed Semantics - Free Functions]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_make_optional_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T> make_optional( T const& v )`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-05-18 01:09:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_make_optional_rvalue]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<std::decay_t<T>> make_optional( T && v )`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns: ] `optional<std::decay_t<T>>(std::move(v))` for the ['deduced] type `T` of `v`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_make_optional_bool_value]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `optional<T> make_optional( bool condition, T const& v )`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns: ] `optional<T>(condition, v)` for the ['deduced] type `T` of `v`.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*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");
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2017-05-18 01:09:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_make_optional_bool_rvalue]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `optional<std::decay_t<T>> make_optional( bool condition, T && v )`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns: ] `optional<std::decay_t<T>>(condition, std::move(v))` for the ['deduced] type `T` of `v`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_equal_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator == ( optional<T> const& x, optional<T> const& y );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-07-30 10:09:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] `T` shall meet requirements of __STD_EQUALITY_COMPARABLE__.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] If both `x` and `y` are initialized, `(*x == *y)`. If only
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`x` or `y` is initialized, `false`. If both are uninitialized, `true`.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-09 11:50:10 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__FUNCTION_EQUAL_POINTEES__ instead
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								optional<T> oN, oN_;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> o1(T(1)), o1_(T(1));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> o2(T(2));
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( oN == oN );  // Identity implies equality
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( o1 == o1 );  //
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( oN == oN_ ); // Both uninitialized compare equal
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( oN != o1 );  // Initialized unequal to initialized.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( o1 == o1_ ); // Both initialized compare as (*lhs == *rhs)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( o1 != o2 );  //
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_less_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator < ( optional<T> const& x, optional<T> const& y );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] Expression `*x < *y` shall be well-formed and its result shall be convertible to `bool`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `(!y) ? false : (!x) ? true : *x < *y`.
							 
						 
					
						
							
								
									
										
										
										
											2015-03-09 11:50:10 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*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
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:31 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								which expect to be given either an `optional<T>` or a pointer; use __FUNCTION_LESS_POINTEES__ instead. `T` need not be __STD_LESS_THAN_COMPARABLE__. Only single `operator<` is required. Other relational operations are defined in terms of this one. If `T`'s `operator<` satisfies the axioms of __STD_LESS_THAN_COMPARABLE__ (transitivity, antisymmetry and irreflexivity), `optional<T>` is __STD_LESS_THAN_COMPARABLE__.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Example:]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								optional<T> oN, oN_;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> o0(T(0));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								optional<T> o1(T(1));
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( !(oN < oN) );  // Identity implies equivalence
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !(o1 < o1) );
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( !(oN < oN_) ); // Two uninitialized are equivalent
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !(oN_ < oN) );
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( oN < o0 );     // Uninitialized is less than initialized
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !(o0 < oN) );
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								assert ( o1 < o2 ) ;    // Two initialized compare as (*lhs < *rhs)
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !(o2 < o1) ) ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								assert ( !(o2 < o2) ) ;
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_not_equal_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator != ( optional<T> const& x, optional<T> const& y );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns: ] `!( x == y );`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_greater_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator > ( optional<T> const& x, optional<T> const& y );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns: ] `( y < x );`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_less_or_equal_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator <= ( optional<T> const& x, optional<T> const& y );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:59:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns: ] `!( y < x );`
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_greater_or_equal_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator >= ( optional<T> const& x, optional<T> const& y );`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns: ] `!( x < y );`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:59:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_equal_optional_none]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator == ( optional<T> const& x, none_t ) noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `bool operator == ( none_t, optional<T> const& x ) noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:59:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Returns:] `!x`.
							 
						 
					
						
							
								
									
										
										
										
											2022-07-30 10:09:35 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Notes:] `T` need not meet requirements of __STD_EQUALITY_COMPARABLE__.
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:59:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_operator_compare_not_equal_optional_none]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `bool operator != ( optional<T> const& x, none_t ) noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `bool operator != ( none_t, optional<T> const& x ) noexcept;`]
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:59:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-09 18:16:02 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Returns: ] `bool(x);`
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 22:59:06 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_free_get_pointer]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_free_get_value_or]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `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.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_swap_optional_optional]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[: `void swap ( optional<T>& x, optional<T>& y ) ;`]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2014-06-20 16:25:57 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Requires:] Lvalues of type `T` shall be swappable and `T` shall be __MOVE_CONSTRUCTIBLE__.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Effects:]
							 
						 
					
						
							
								
									
										
										
										
											2018-07-02 23:07:47 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[table
							 
						 
					
						
							
								
									
										
										
										
											2015-05-27 17:06:31 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								  []
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								  [[][[*`*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]]
							 
						 
					
						
							
								
									
										
										
										
											2015-03-06 19:20:45 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*Postconditions:] The states of `x` and `y` interchanged.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*Throws:] If both are initialized, whatever `swap(T&,T&)` throws. If only
							 
						 
					
						
							
								
									
										
										
										
											2014-04-29 01:06:14 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								one is initialized, whatever `T::T ( T&& )` throws.
							 
						 
					
						
							
								
									
										
										
										
											2007-05-29 06:40:25 +00:00 
										
									 
								 
							 
							
								
							 
							
								 
							 
							
							
								* [*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 );
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_swap_optional_reference]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[: `void swap ( optional<T&>& x, optional<T&>& y ) noexcept ;`]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-11-01 21:46:35 -04:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								* [*Postconditions:] `x` refers to what `y` referred to before the swap (if anything). `y` refers to whatever `x` referred to before the swap.
							 
						 
					
						
							
								
									
										
										
										
											2016-02-16 21:05:01 +01:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								* [*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));
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2016-09-09 18:16:02 -05:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								[endsect]
							 
						 
					
						
							
								
									
										
										
										
											2022-05-23 21:00:00 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[section Detailed Semantics - std::hash Specializations]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								__SPACE__
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[#reference_std_hash_spec]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								namespace std {
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template <typename T>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct hash<boost::optional<T> > ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								template <typename T>
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								struct hash<boost::optional<T&> > ;
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								} // namespace std
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								``
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
									
										
										
										
											2022-05-23 22:42:04 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								The specialization `hash<optional<T>>` is enabled if and only if
							 
						 
					
						
							
								
									
										
										
										
											2024-01-02 18:04:08 +03:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								`hash<remove_const_t<T>>` is enabled. When enabled, for an object `o`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								of type `optional<T>`, if `o.has_value() == true`, then `hash<optional<T>>()(o)`
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								 evaluates to the same value as `hash<remove_const_t<T>>()(*o)`; otherwise it
							 
						 
					
						
							
								
									
										
										
										
											2022-05-23 21:00:00 +02:00 
										
									 
								 
							 
							
								
									
										 
									 
								
							 
							
								 
							 
							
							
								evaluates to an unspecified value.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								The member functions are not guaranteed to be `noexcept`.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[caution
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								You may get compiler errors when your program provides specializations for
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`std::hash<boost::optional<T>>`. If this happens, define macro
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								`BOOST_OPTIONAL_CONFIG_DO_NOT_SPECIALIZE_STD_HASH` to suppress the specializations
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								of `std::hash` in this library.
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								]
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								
							 
						 
					
						
							
								
							 
							
								
							 
							
								 
							 
							
							
								[endsect]