Fix make_optional for rvalues

This commit is contained in:
Andrzej Krzemienski
2017-05-18 01:09:31 +02:00
parent c695be11b5
commit 4fe57f57fa
48 changed files with 280 additions and 44 deletions

View File

@ -152,6 +152,18 @@ class optional_base : public optional_tag
construct(val);
}
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
// Creates an optional<T> initialized with 'move(val)' IFF cond is true, otherwise creates an uninitialzed optional<T>.
// Can throw if T::T(T &&) does
optional_base ( bool cond, rval_reference_type val )
:
m_initialized(false)
{
if ( cond )
construct(boost::move(val));
}
#endif
// Creates a deep copy of another optional<T>
// Can throw if T::T(T const&) does
optional_base ( optional_base const& rhs )
@ -810,6 +822,13 @@ class optional : public optional_detail::optional_base<T>
// 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) )
{}
#endif
// NOTE: MSVC needs templated versions first
// Creates a deep copy of another convertible optional<U>