src/cxx_supportlib/vendor-modified/boost/optional/optional.hpp in passenger-6.0.2 vs src/cxx_supportlib/vendor-modified/boost/optional/optional.hpp in passenger-6.0.3
- old
+ new
@@ -1,7 +1,7 @@
// Copyright (C) 2003, 2008 Fernando Luis Cacciola Carballal.
-// Copyright (C) 2014 - 2017 Andrzej Krzemienski.
+// Copyright (C) 2014 - 2018 Andrzej Krzemienski.
//
// Use, modification, and distribution is subject to 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)
//
@@ -51,51 +51,69 @@
#include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/is_scalar.hpp>
#include <boost/move/utility.hpp>
#include <boost/none.hpp>
#include <boost/utility/compare_pointees.hpp>
+#include <boost/utility/result_of.hpp>
#include <boost/optional/optional_fwd.hpp>
#include <boost/optional/detail/optional_config.hpp>
#include <boost/optional/detail/optional_factory_support.hpp>
#include <boost/optional/detail/optional_aligned_storage.hpp>
+namespace boost { namespace optional_detail {
+
+template <typename T>
+struct optional_value_type
+{
+};
+
+template <typename T>
+struct optional_value_type< ::boost::optional<T> >
+{
+ typedef T type;
+};
+
+}} // namespace boost::optional_detail
+
#ifdef BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL
#include <boost/optional/detail/old_optional_implementation.hpp>
#else
namespace boost {
-
+
namespace optional_ns {
-
+
// a tag for in-place initialization of contained value
struct in_place_init_t
{
struct init_tag{};
explicit in_place_init_t(init_tag){}
-};
+};
const in_place_init_t in_place_init ((in_place_init_t::init_tag()));
// a tag for conditional in-place initialization of contained value
struct in_place_init_if_t
{
struct init_tag{};
explicit in_place_init_if_t(init_tag){}
};
const in_place_init_if_t in_place_init_if ((in_place_init_if_t::init_tag()));
-
+
} // namespace optional_ns
using optional_ns::in_place_init_t;
using optional_ns::in_place_init;
using optional_ns::in_place_init_if_t;
using optional_ns::in_place_init_if;
namespace optional_detail {
-struct optional_tag {} ;
+struct init_value_tag {};
+struct optional_tag {};
+
template<class T>
class optional_base : public optional_tag
{
private :
@@ -129,21 +147,21 @@
:
m_initialized(false) {}
// Creates an optional<T> initialized with 'val'.
// Can throw if T::T(T const&) does
- optional_base ( argument_type val )
+ optional_base ( init_value_tag, argument_type val )
:
m_initialized(false)
{
construct(val);
}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// move-construct an optional<T> initialized from an rvalue-ref to 'val'.
// Can throw if T::T(T&&) does
- optional_base ( rval_reference_type val )
+ optional_base ( init_value_tag, rval_reference_type val )
:
m_initialized(false)
{
construct( boost::move(val) );
}
@@ -249,11 +267,11 @@
{
if ( rhs.is_initialized() )
construct(rhs.get_impl());
}
}
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Assigns from another optional<T> (deep-moves the rhs value)
void assign ( optional_base&& rhs )
{
if (is_initialized())
@@ -266,11 +284,11 @@
{
if ( rhs.is_initialized() )
construct(boost::move(rhs.get_impl()));
}
}
-#endif
+#endif
// Assigns from another _convertible_ optional<U> (deep-copies the rhs value)
template<class U>
void assign ( optional<U> const& rhs )
{
@@ -280,11 +298,11 @@
#ifndef BOOST_OPTIONAL_CONFIG_RESTORE_ASSIGNMENT_OF_NONCONVERTIBLE_TYPES
assign_value( rhs.get() );
#else
assign_value( static_cast<value_type>(rhs.get()) );
#endif
-
+
else destroy();
}
else
{
if ( rhs.is_initialized() )
@@ -313,19 +331,19 @@
if ( rhs.is_initialized() )
construct(static_cast<ref_type>(rhs.get()));
}
}
#endif
-
+
// Assigns from a T (deep-copies the rhs value)
void assign ( argument_type val )
{
if (is_initialized())
assign_value(val);
else construct(val);
}
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Assigns from a T (deep-moves the rhs value)
void assign ( rval_reference_type val )
{
if (is_initialized())
@@ -360,11 +378,11 @@
#endif
public :
- // **DEPPRECATED** Destroys the current value, if any, leaving this UNINITIALIZED
+ // Destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
void reset() BOOST_NOEXCEPT { destroy(); }
// **DEPPRECATED** Replaces the current value -if any- with 'val'
void reset ( argument_type val ) { assign(val); }
@@ -373,20 +391,20 @@
// returns NULL.
// No-throw
pointer_const_type get_ptr() const { return m_initialized ? get_ptr_impl() : 0 ; }
pointer_type get_ptr() { return m_initialized ? get_ptr_impl() : 0 ; }
- bool is_initialized() const { return m_initialized ; }
+ bool is_initialized() const BOOST_NOEXCEPT { return m_initialized ; }
protected :
void construct ( argument_type val )
{
::new (m_storage.address()) value_type(val) ;
m_initialized = true ;
}
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
void construct ( rval_reference_type val )
{
::new (m_storage.address()) value_type( boost::move(val) ) ;
m_initialized = true ;
@@ -408,19 +426,19 @@
void emplace_assign ( Args&&... args )
{
destroy();
construct(in_place_init, boost::forward<Args>(args)...);
}
-
+
template<class... Args>
explicit optional_base ( in_place_init_t, Args&&... args )
:
m_initialized(false)
{
construct(in_place_init, boost::forward<Args>(args)...);
}
-
+
template<class... Args>
explicit optional_base ( in_place_init_if_t, bool cond, Args&&... args )
:
m_initialized(false)
{
@@ -432,78 +450,78 @@
void construct ( in_place_init_t, Arg&& arg )
{
::new (m_storage.address()) value_type( boost::forward<Arg>(arg) );
m_initialized = true ;
}
-
+
void construct ( in_place_init_t )
{
::new (m_storage.address()) value_type();
m_initialized = true ;
}
-
+
template<class Arg>
void emplace_assign ( Arg&& arg )
{
destroy();
construct(in_place_init, boost::forward<Arg>(arg)) ;
}
-
+
void emplace_assign ()
{
destroy();
construct(in_place_init) ;
}
-
+
template<class Arg>
explicit optional_base ( in_place_init_t, Arg&& arg )
:
m_initialized(false)
{
construct(in_place_init, boost::forward<Arg>(arg));
}
-
+
explicit optional_base ( in_place_init_t )
:
m_initialized(false)
{
construct(in_place_init);
}
-
+
template<class Arg>
explicit optional_base ( in_place_init_if_t, bool cond, Arg&& arg )
:
m_initialized(false)
{
if ( cond )
construct(in_place_init, boost::forward<Arg>(arg));
}
-
+
explicit optional_base ( in_place_init_if_t, bool cond )
:
m_initialized(false)
{
if ( cond )
construct(in_place_init);
}
#else
-
+
template<class Arg>
void construct ( in_place_init_t, const Arg& arg )
{
::new (m_storage.address()) value_type( arg );
m_initialized = true ;
}
-
+
template<class Arg>
void construct ( in_place_init_t, Arg& arg )
{
::new (m_storage.address()) value_type( arg );
m_initialized = true ;
}
-
+
void construct ( in_place_init_t )
{
::new (m_storage.address()) value_type();
m_initialized = true ;
}
@@ -512,24 +530,24 @@
void emplace_assign ( const Arg& arg )
{
destroy();
construct(in_place_init, arg);
}
-
+
template<class Arg>
void emplace_assign ( Arg& arg )
{
destroy();
construct(in_place_init, arg);
}
-
+
void emplace_assign ()
{
destroy();
construct(in_place_init);
}
-
+
template<class Arg>
explicit optional_base ( in_place_init_t, const Arg& arg )
: m_initialized(false)
{
construct(in_place_init, arg);
@@ -539,33 +557,33 @@
explicit optional_base ( in_place_init_t, Arg& arg )
: m_initialized(false)
{
construct(in_place_init, arg);
}
-
+
explicit optional_base ( in_place_init_t )
: m_initialized(false)
{
construct(in_place_init);
}
-
+
template<class Arg>
explicit optional_base ( in_place_init_if_t, bool cond, const Arg& arg )
: m_initialized(false)
{
if ( cond )
construct(in_place_init, arg);
}
-
+
template<class Arg>
explicit optional_base ( in_place_init_if_t, bool cond, Arg& arg )
: m_initialized(false)
{
if ( cond )
construct(in_place_init, arg);
- }
-
+ }
+
explicit optional_base ( in_place_init_if_t, bool cond )
: m_initialized(false)
{
if ( cond )
construct(in_place_init);
@@ -755,12 +773,10 @@
bool m_initialized ;
storage_type m_storage ;
} ;
-
-
#include <boost/optional/detail/optional_trivially_copyable_base.hpp>
// definition of metafunciton is_optional_val_init_candidate
template <typename U>
struct is_optional_related
@@ -770,11 +786,11 @@
|| boost::is_same<BOOST_DEDUCED_TYPENAME boost::decay<U>::type, in_place_init_if_t>::value,
boost::true_type, boost::false_type>::type
{};
#if !defined(BOOST_OPTIONAL_DETAIL_NO_IS_CONSTRUCTIBLE_TRAIT)
-
+
template <typename T, typename U>
struct is_convertible_to_T_or_factory
: boost::conditional< boost::is_base_of<boost::in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value
|| boost::is_base_of<boost::typed_in_place_factory_base, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value
|| (boost::is_constructible<T, U&&>::value && !boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<U>::type>::value)
@@ -854,27 +870,27 @@
// No-throw
optional( none_t none_ ) BOOST_NOEXCEPT : base(none_) {}
// Creates an optional<T> initialized with 'val'.
// Can throw if T::T(T const&) does
- optional ( argument_type val ) : base(val) {}
+ optional ( argument_type val ) : base(optional_detail::init_value_tag(), val) {}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Creates an optional<T> initialized with 'move(val)'.
// Can throw if T::T(T &&) does
- optional ( rval_reference_type val ) : base( boost::forward<T>(val) )
+ optional ( rval_reference_type val ) : base(optional_detail::init_value_tag(), boost::forward<T>(val))
{}
#endif
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional.
// Can throw if T::T(T const&) does
optional ( bool cond, argument_type val ) : base(cond,val) {}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
/// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional.
// Can throw if T::T(T &&) does
- optional ( bool cond, rval_reference_type val ) : base( cond, boost::forward<T>(val) )
+ optional ( bool cond, rval_reference_type val ) : base( cond, boost::forward<T>(val) )
{}
#endif
// NOTE: MSVC needs templated versions first
@@ -887,15 +903,15 @@
,BOOST_DEDUCED_TYPENAME boost::enable_if< optional_detail::is_optional_constructible<T, U const&>, bool>::type = true
#endif
)
:
base()
- {
+ {
if ( rhs.is_initialized() )
this->construct(rhs.get());
}
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Creates a deep move of another convertible optional<U>
// Requires a valid conversion from U to T.
// Can throw if T::T(U&&) does
template<class U>
@@ -924,14 +940,14 @@
// Can throw if the resolved T ctor throws.
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class Expr>
- explicit optional ( Expr&& expr,
- BOOST_DEDUCED_TYPENAME boost::enable_if< optional_detail::is_optional_val_init_candidate<T, Expr>, bool>::type = true
- )
- : base(boost::forward<Expr>(expr),boost::addressof(expr))
+ explicit optional ( Expr&& expr,
+ BOOST_DEDUCED_TYPENAME boost::enable_if< optional_detail::is_optional_val_init_candidate<T, Expr>, bool>::type = true
+ )
+ : base(boost::forward<Expr>(expr),boost::addressof(expr))
{}
#else
template<class Expr>
explicit optional ( Expr const& expr ) : base(expr,boost::addressof(expr)) {}
@@ -971,11 +987,11 @@
// Assigns from an expression. See corresponding constructor.
// Basic Guarantee: If the resolved T ctor throws, this is left UNINITIALIZED
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class Expr>
- BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_init_candidate<T, Expr>, optional&>::type
+ BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_init_candidate<T, Expr>, optional&>::type
operator= ( Expr&& expr )
{
this->assign_expr(boost::forward<Expr>(expr),boost::addressof(expr));
return *this ;
}
@@ -997,11 +1013,11 @@
optional& operator= ( optional<U> const& rhs )
{
this->assign(rhs);
return *this ;
}
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Move-assigns from another convertible optional<U> (converts && deep-moves the rhs value)
// Requires a valid conversion from U to T.
// Basic Guarantee: If T::T( U && ) throws, this is left UNINITIALIZED
template<class U>
@@ -1028,18 +1044,18 @@
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Assigns from another optional<T> (deep-moves the rhs value)
#ifndef BOOST_OPTIONAL_DETAIL_NO_DEFAULTED_MOVE_FUNCTIONS
optional& operator= ( optional && ) = default;
#else
- optional& operator= ( optional && rhs )
+ optional& operator= ( optional && rhs )
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
{
this->assign( static_cast<base &&>(rhs) ) ;
return *this ;
}
-#endif
-
+#endif
+
#endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
#ifndef BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
// Assigns from a T (deep-moves/copies the rhs value)
@@ -1048,131 +1064,131 @@
operator= ( T_&& val )
{
this->assign( boost::forward<T_>(val) ) ;
return *this ;
}
-
+
#else
// Assigns from a T (deep-copies the rhs value)
// Basic Guarantee: If T::( T const& ) throws, this is left UNINITIALIZED
optional& operator= ( argument_type val )
{
this->assign( val ) ;
return *this ;
}
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Assigns from a T (deep-moves the rhs value)
optional& operator= ( rval_reference_type val )
{
this->assign( boost::move(val) ) ;
return *this ;
}
#endif
-
+
#endif // BOOST_NO_CXX11_UNIFIED_INITIALIZATION_SYNTAX
-
+
// Assigns from a "none"
// Which destroys the current value, if any, leaving this UNINITIALIZED
// No-throw (assuming T::~T() doesn't)
optional& operator= ( none_t none_ ) BOOST_NOEXCEPT
{
this->assign( none_ ) ;
return *this ;
}
-
+
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
// Constructs in-place
// upon exception *this is always uninitialized
template<class... Args>
void emplace ( Args&&... args )
{
this->emplace_assign( boost::forward<Args>(args)... );
}
-
+
template<class... Args>
explicit optional ( in_place_init_t, Args&&... args )
: base( in_place_init, boost::forward<Args>(args)... )
{}
-
+
template<class... Args>
explicit optional ( in_place_init_if_t, bool cond, Args&&... args )
: base( in_place_init_if, cond, boost::forward<Args>(args)... )
{}
-
+
#elif (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
template<class Arg>
void emplace ( Arg&& arg )
{
this->emplace_assign( boost::forward<Arg>(arg) );
}
-
+
void emplace ()
{
this->emplace_assign();
}
-
+
template<class Args>
explicit optional ( in_place_init_t, Args&& args )
: base( in_place_init, boost::forward<Args>(args) )
{}
explicit optional ( in_place_init_t )
: base( in_place_init )
{}
-
+
template<class Args>
explicit optional ( in_place_init_if_t, bool cond, Args&& args )
: base( in_place_init_if, cond, boost::forward<Args>(args) )
{}
-
+
explicit optional ( in_place_init_if_t, bool cond )
: base( in_place_init_if, cond )
{}
#else
template<class Arg>
void emplace ( const Arg& arg )
{
this->emplace_assign( arg );
}
-
+
template<class Arg>
void emplace ( Arg& arg )
{
this->emplace_assign( arg );
}
-
+
void emplace ()
{
this->emplace_assign();
}
-
+
template<class Arg>
explicit optional ( in_place_init_t, const Arg& arg )
: base( in_place_init, arg )
{}
-
+
template<class Arg>
explicit optional ( in_place_init_t, Arg& arg )
: base( in_place_init, arg )
{}
explicit optional ( in_place_init_t )
: base( in_place_init )
{}
-
+
template<class Arg>
explicit optional ( in_place_init_if_t, bool cond, const Arg& arg )
: base( in_place_init_if, cond, arg )
{}
-
+
template<class Arg>
explicit optional ( in_place_init_if_t, bool cond, Arg& arg )
: base( in_place_init_if, cond, arg )
- {}
-
+ {}
+
explicit optional ( in_place_init_if_t, bool cond )
: base( in_place_init_if, cond )
{}
#endif
@@ -1201,55 +1217,55 @@
pointer_type operator->() { BOOST_ASSERT(this->is_initialized()) ; return this->get_ptr_impl() ; }
// Returns a reference to the value if this is initialized, otherwise,
// the behaviour is UNDEFINED
// No-throw
-#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
+#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
reference_const_type operator *() const& { return this->get() ; }
reference_type operator *() & { return this->get() ; }
reference_type_of_temporary_wrapper operator *() && { return boost::move(this->get()) ; }
#else
reference_const_type operator *() const { return this->get() ; }
reference_type operator *() { return this->get() ; }
#endif // !defined BOOST_NO_CXX11_REF_QUALIFIERS
-#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
+#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
reference_const_type value() const&
- {
+ {
if (this->is_initialized())
return this->get() ;
else
throw_exception(bad_optional_access());
}
-
+
reference_type value() &
- {
+ {
if (this->is_initialized())
return this->get() ;
else
throw_exception(bad_optional_access());
}
-
+
reference_type_of_temporary_wrapper value() &&
- {
+ {
if (this->is_initialized())
return boost::move(this->get()) ;
else
throw_exception(bad_optional_access());
}
-#else
+#else
reference_const_type value() const
- {
+ {
if (this->is_initialized())
return this->get() ;
else
throw_exception(bad_optional_access());
}
-
+
reference_type value()
- {
+ {
if (this->is_initialized())
return this->get() ;
else
throw_exception(bad_optional_access());
}
@@ -1257,95 +1273,189 @@
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
template <class U>
value_type value_or ( U&& v ) const&
- {
+ {
if (this->is_initialized())
return get();
else
return boost::forward<U>(v);
}
-
+
template <class U>
- value_type value_or ( U&& v ) &&
- {
+ value_type value_or ( U&& v ) &&
+ {
if (this->is_initialized())
return boost::move(get());
else
return boost::forward<U>(v);
}
#elif !defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template <class U>
- value_type value_or ( U&& v ) const
+ value_type value_or ( U&& v ) const
{
if (this->is_initialized())
return get();
else
return boost::forward<U>(v);
}
#else
template <class U>
- value_type value_or ( U const& v ) const
- {
+ value_type value_or ( U const& v ) const
+ {
if (this->is_initialized())
return get();
else
return v;
}
-
+
template <class U>
- value_type value_or ( U& v ) const
- {
+ value_type value_or ( U& v ) const
+ {
if (this->is_initialized())
return get();
else
return v;
}
#endif
-#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
+#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
template <typename F>
value_type value_or_eval ( F f ) const&
{
if (this->is_initialized())
return get();
else
return f();
}
-
+
template <typename F>
value_type value_or_eval ( F f ) &&
{
if (this->is_initialized())
return boost::move(get());
else
return f();
}
+
+ template <typename F>
+ optional<typename boost::result_of<F(reference_type)>::type> map(F f) &
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename boost::result_of<F(reference_const_type)>::type> map(F f) const&
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename boost::result_of<F(reference_type_of_temporary_wrapper)>::type> map(F f) &&
+ {
+ if (this->has_value())
+ return f(boost::move(this->get()));
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename optional_detail::optional_value_type<typename boost::result_of<F(reference_type)>::type>::type> flat_map(F f) &
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename optional_detail::optional_value_type<typename boost::result_of<F(reference_const_type)>::type>::type> flat_map(F f) const&
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename optional_detail::optional_value_type<typename boost::result_of<F(reference_type_of_temporary_wrapper)>::type>::type> flat_map(F f) &&
+ {
+ if (this->has_value())
+ return f(boost::move(get()));
+ else
+ return none;
+ }
+
#else
template <typename F>
value_type value_or_eval ( F f ) const
{
if (this->is_initialized())
return get();
else
return f();
}
+
+ template <typename F>
+ optional<typename boost::result_of<F(reference_type)>::type> map(F f)
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename boost::result_of<F(reference_const_type)>::type> map(F f) const
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename optional_detail::optional_value_type<typename boost::result_of<F(reference_type)>::type>::type> flat_map(F f)
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
+ template <typename F>
+ optional<typename optional_detail::optional_value_type<typename boost::result_of<F(reference_const_type)>::type>::type> flat_map(F f) const
+ {
+ if (this->has_value())
+ return f(get());
+ else
+ return none;
+ }
+
#endif
-
+
+ bool has_value() const BOOST_NOEXCEPT { return this->is_initialized() ; }
+
bool operator!() const BOOST_NOEXCEPT { return !this->is_initialized() ; }
-
+
BOOST_EXPLICIT_OPERATOR_BOOL_NOEXCEPT()
} ;
} // namespace boost
#endif // BOOST_OPTIONAL_CONFIG_USE_OLD_IMPLEMENTATION_OF_OPTIONAL
namespace boost {
-
+
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
template<class T>
class optional<T&&>
{
BOOST_STATIC_ASSERT_MSG(sizeof(T) == 0, "Optional rvalue references are illegal.");
@@ -1470,17 +1580,17 @@
}
} // namespace boost
namespace boost {
-
+
// The following declaration prevents a bug where operator safe-bool is used upon streaming optional object if you forget the IO header.
template<class CharType, class CharTrait>
std::basic_ostream<CharType, CharTrait>&
operator<<(std::basic_ostream<CharType, CharTrait>& os, optional_detail::optional_tag const&)
{
BOOST_STATIC_ASSERT_MSG(sizeof(CharType) == 0, "If you want to output boost::optional, include header <boost/optional/optional_io.hpp>");
- return os;
+ return os;
}
} // namespace boost
#include <boost/optional/detail/optional_relops.hpp>