mirror of
https://github.com/boostorg/optional.git
synced 2025-07-16 13:52:08 +02:00
bug fixes
This commit is contained in:
@ -133,25 +133,30 @@ public:
|
||||
#else // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
|
||||
template <class U>
|
||||
optional(const U& v) BOOST_NOEXCEPT : ptr_(boost::addressof(v)) { }
|
||||
optional(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT : ptr_(boost::addressof(v)) { }
|
||||
|
||||
template <class U>
|
||||
optional(bool cond, const U& v) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}
|
||||
optional(bool cond, U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT : ptr_(cond ? boost::addressof(v) : 0) {}
|
||||
|
||||
template <class U>
|
||||
optional operator=(const U& v) BOOST_NOEXCEPT { ptr_ = boost::addressof(v); return *this; }
|
||||
BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U>, optional<T&>&>::type
|
||||
operator=(U& v) BOOST_NOEXCEPT { ptr_ = boost::addressof(v); return *this; }
|
||||
|
||||
template <class U>
|
||||
void emplace(const U& v) BOOST_NOEXCEPT { ptr_ = boost::addressof(v); }
|
||||
void emplace(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
|
||||
{ ptr_ = boost::addressof(v); }
|
||||
|
||||
template <class U>
|
||||
T& get_value_or(const U& v) const BOOST_NOEXCEPT { return ptr_ ? *ptr_ : v; }
|
||||
T& get_value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
|
||||
{ return ptr_ ? *ptr_ : v; }
|
||||
|
||||
template <class U>
|
||||
T& value_or(const U& v) const BOOST_NOEXCEPT { return ptr_ ? *ptr_ : v; }
|
||||
T& value_or(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) const BOOST_NOEXCEPT
|
||||
{ return ptr_ ? *ptr_ : v; }
|
||||
|
||||
template <class U>
|
||||
void reset(const U& v) BOOST_NOEXCEPT { ptr_ = boost::addressof(v); }
|
||||
void reset(U& v, BOOST_DEDUCED_TYPENAME boost::enable_if<detail::is_no_optional<U> >::type* = 0) BOOST_NOEXCEPT
|
||||
{ ptr_ = boost::addressof(v); }
|
||||
|
||||
#endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
};
|
||||
|
@ -24,7 +24,7 @@
|
||||
using boost::optional;
|
||||
using boost::none;
|
||||
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
|
||||
class Guard
|
||||
{
|
||||
@ -90,7 +90,7 @@ void test_emplace()
|
||||
|
||||
#endif
|
||||
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
|
||||
|
||||
|
||||
struct ThrowOnMove
|
||||
@ -120,7 +120,7 @@ struct Thrower
|
||||
|
||||
private:
|
||||
Thrower(Thrower const&);
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
|
||||
Thrower(Thrower&&);
|
||||
#endif
|
||||
};
|
||||
@ -192,10 +192,10 @@ void test_emplace()
|
||||
|
||||
int main()
|
||||
{
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES) && (!defined BOOST_NO_CXX11_VARIADIC_TEMPLATES)
|
||||
test_emplace();
|
||||
#endif
|
||||
#if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
|
||||
#if (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
|
||||
test_no_moves_on_emplacement();
|
||||
#endif
|
||||
test_clear_on_throw();
|
||||
|
@ -24,7 +24,7 @@ using boost::none;
|
||||
//#ifndef BOOST_OPTIONAL_NO_CONVERTING_ASSIGNMENT
|
||||
//#ifndef BOOST_OPTIONAL_NO_CONVERTING_COPY_CTOR
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
|
||||
enum State
|
||||
{
|
||||
@ -334,7 +334,7 @@ void test_optional_ref_to_movables()
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
test_move_ctor_from_U();
|
||||
test_move_ctor_form_T();
|
||||
test_move_ctor_from_optional_T();
|
||||
|
@ -20,7 +20,7 @@
|
||||
using boost::optional;
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
#ifndef BOOST_NO_CXX11_NOEXCEPT
|
||||
|
||||
// these 4 classes have different noexcept signatures in move operations
|
||||
@ -106,7 +106,7 @@ void test_noexcept_optional_with_operator() // compile-time test
|
||||
}
|
||||
|
||||
#endif // !defned BOOST_NO_CXX11_NOEXCEPT
|
||||
#endif // !defined BOOST_NO_CXX11_RVALUE_REFERENCES
|
||||
#endif // !defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
|
||||
|
||||
int main()
|
||||
{
|
||||
|
@ -175,7 +175,7 @@ void test_const_move()
|
||||
}
|
||||
|
||||
|
||||
#ifndef BOOST_NO_CXX11_REF_QUALIFIERS
|
||||
#if (!defined BOOST_NO_CXX11_REF_QUALIFIERS) && (!defined BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES)
|
||||
struct MoveOnly
|
||||
{
|
||||
explicit MoveOnly(int){}
|
||||
|
Reference in New Issue
Block a user