refactor: drop Boost.Move dependency

Implement constexpr definitions of forward and move to replace usage
of boost::move and boost::forward from the Boost.Move library.

Alter tests to use std::move instead of boost::move.

Remove the dependency on Boost.Move from build.jam
This commit is contained in:
typenameTea
2024-09-28 17:18:00 +01:00
parent 1820ae55ef
commit cacde054df
13 changed files with 113 additions and 78 deletions

View File

@ -17,7 +17,6 @@ target_link_libraries(boost_optional
Boost::assert Boost::assert
Boost::config Boost::config
Boost::core Boost::core
Boost::move
Boost::static_assert Boost::static_assert
Boost::throw_exception Boost::throw_exception
Boost::type_traits Boost::type_traits

View File

@ -9,7 +9,6 @@ constant boost_dependencies :
/boost/assert//boost_assert /boost/assert//boost_assert
/boost/config//boost_config /boost/config//boost_config
/boost/core//boost_core /boost/core//boost_core
/boost/move//boost_move
/boost/static_assert//boost_static_assert /boost/static_assert//boost_static_assert
/boost/throw_exception//boost_throw_exception /boost/throw_exception//boost_throw_exception
/boost/type_traits//boost_type_traits ; /boost/type_traits//boost_type_traits ;

View File

@ -17,7 +17,6 @@ The implementation uses the following other Boost modules:
# assert # assert
# config # config
# core # core
# move
# static_assert # static_assert
# throw_exception # throw_exception
# type_traits # type_traits

View File

@ -39,7 +39,7 @@ BOOST_DEDUCED_TYPENAME boost::remove_reference<T>::type& forward_reference(T&& r
{ {
BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference<T>::value, BOOST_STATIC_ASSERT_MSG(boost::is_lvalue_reference<T>::value,
"binding rvalue references to optional lvalue references is disallowed"); "binding rvalue references to optional lvalue references is disallowed");
return boost::forward<T>(r); return optional_detail::forward<T>(r);
} }
#endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES #endif // BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES

View File

@ -54,7 +54,7 @@ struct swap_selector<true>
#endif #endif
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
# define BOOST_OPTIONAL_DETAIL_MOVE(EXPR_) boost::move(EXPR_) # define BOOST_OPTIONAL_DETAIL_MOVE(EXPR_) optional_detail::move(EXPR_)
#else #else
# define BOOST_OPTIONAL_DETAIL_MOVE(EXPR_) EXPR_ # define BOOST_OPTIONAL_DETAIL_MOVE(EXPR_) EXPR_
#endif #endif

View File

@ -54,7 +54,7 @@ class tc_optional_base : public optional_tag
: :
m_initialized(false) m_initialized(false)
{ {
construct(boost::forward<Expr>(expr),tag); construct(optional_detail::forward<Expr>(expr),tag);
} }
// tc_optional_base& operator= ( tc_optional_base const& ) = default; // tc_optional_base& operator= ( tc_optional_base const& ) = default;
@ -102,7 +102,7 @@ class tc_optional_base : public optional_tag
template<class Expr, class ExprPtr> template<class Expr, class ExprPtr>
void assign_expr ( Expr&& expr, ExprPtr const* tag ) void assign_expr ( Expr&& expr, ExprPtr const* tag )
{ {
construct(boost::forward<Expr>(expr),tag); construct(optional_detail::forward<Expr>(expr),tag);
} }
#endif #endif
@ -138,14 +138,14 @@ class tc_optional_base : public optional_tag
template<class... Args> template<class... Args>
void construct ( in_place_init_t, Args&&... args ) void construct ( in_place_init_t, Args&&... args )
{ {
m_storage = value_type( boost::forward<Args>(args)... ) ; m_storage = value_type( optional_detail::forward<Args>(args)... ) ;
m_initialized = true ; m_initialized = true ;
} }
template<class... Args> template<class... Args>
void emplace_assign ( Args&&... args ) void emplace_assign ( Args&&... args )
{ {
construct(in_place_init, boost::forward<Args>(args)...); construct(in_place_init, optional_detail::forward<Args>(args)...);
} }
template<class... Args> template<class... Args>
@ -153,7 +153,7 @@ class tc_optional_base : public optional_tag
: :
m_initialized(false) m_initialized(false)
{ {
construct(in_place_init, boost::forward<Args>(args)...); construct(in_place_init, optional_detail::forward<Args>(args)...);
} }
template<class... Args> template<class... Args>
@ -162,7 +162,7 @@ class tc_optional_base : public optional_tag
m_initialized(false) m_initialized(false)
{ {
if ( cond ) if ( cond )
construct(in_place_init, boost::forward<Args>(args)...); construct(in_place_init, optional_detail::forward<Args>(args)...);
} }
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
@ -207,7 +207,7 @@ class tc_optional_base : public optional_tag
template<class Expr> template<class Expr>
void construct ( Expr&& expr, void const* ) void construct ( Expr&& expr, void const* )
{ {
m_storage = value_type(boost::forward<Expr>(expr)) ; m_storage = value_type(optional_detail::forward<Expr>(expr)) ;
m_initialized = true ; m_initialized = true ;
} }
@ -218,7 +218,7 @@ class tc_optional_base : public optional_tag
template<class Expr> template<class Expr>
void assign_expr_to_initialized ( Expr&& expr, void const* ) void assign_expr_to_initialized ( Expr&& expr, void const* )
{ {
assign_value( boost::forward<Expr>(expr) ); assign_value( optional_detail::forward<Expr>(expr) );
} }
#ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION #ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
@ -243,7 +243,7 @@ class tc_optional_base : public optional_tag
{ {
// An exception can be thrown here. // An exception can be thrown here.
// It it happens, THIS will be left uninitialized. // It it happens, THIS will be left uninitialized.
m_storage = value_type(boost::move(expr.get())) ; m_storage = value_type(optional_detail::move(expr.get())) ;
m_initialized = true ; m_initialized = true ;
} }
} }

View File

@ -0,0 +1,38 @@
// Copyright (C) 2024 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)
//
// See http://www.boost.org/libs/optional for documentation.
//
// You are welcome to contact the author at:
// akrzemi1@gmail.com
#ifndef BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_HPP
#define BOOST_OPTIONAL_OPTIONAL_DETAIL_OPTIONAL_UTILITY_HPP
namespace boost {
namespace optional_detail {
// Workaround: forward and move aren't constexpr in C++11
template <class T> inline constexpr T&& forward(typename boost::remove_reference<T>::type& t) noexcept
{
return static_cast<T&&>(t);
}
template <class T> inline constexpr T&& forward(typename boost::remove_reference<T>::type&& t) noexcept
{
BOOST_STATIC_ASSERT_MSG(!boost::is_lvalue_reference<T>::value, "Can not forward an rvalue as an lvalue.");
return static_cast<T&&>(t);
}
template <class T> inline constexpr typename boost::remove_reference<T>::type&& move(T&& t) noexcept
{
return static_cast<typename boost::remove_reference<T>::type&&>(t);
}
} // namespace optional_detail
} // namespace boost
#endif

View File

@ -51,7 +51,6 @@
#include <boost/type_traits/is_same.hpp> #include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/is_volatile.hpp> #include <boost/type_traits/is_volatile.hpp>
#include <boost/type_traits/is_scalar.hpp> #include <boost/type_traits/is_scalar.hpp>
#include <boost/move/utility.hpp>
#include <boost/none.hpp> #include <boost/none.hpp>
#include <boost/optional/optional_fwd.hpp> #include <boost/optional/optional_fwd.hpp>
@ -59,6 +58,7 @@
#include <boost/optional/detail/optional_factory_support.hpp> #include <boost/optional/detail/optional_factory_support.hpp>
#include <boost/optional/detail/optional_aligned_storage.hpp> #include <boost/optional/detail/optional_aligned_storage.hpp>
#include <boost/optional/detail/optional_hash.hpp> #include <boost/optional/detail/optional_hash.hpp>
#include <boost/optional/detail/optional_utility.hpp>
namespace boost { namespace optional_detail { namespace boost { namespace optional_detail {
@ -178,7 +178,7 @@ class optional_base : public optional_tag
: :
m_initialized(false) m_initialized(false)
{ {
construct( boost::move(val) ); construct( optional_detail::move(val) );
} }
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional<T>. // Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional<T>.
@ -198,7 +198,7 @@ class optional_base : public optional_tag
m_initialized(false) m_initialized(false)
{ {
if ( cond ) if ( cond )
construct(boost::move(val)); construct(optional_detail::move(val));
} }
// Creates a deep copy of another optional<T> // Creates a deep copy of another optional<T>
@ -219,7 +219,7 @@ class optional_base : public optional_tag
m_initialized(false) m_initialized(false)
{ {
if ( rhs.is_initialized() ) if ( rhs.is_initialized() )
construct( boost::move(rhs.get_impl()) ); construct( optional_detail::move(rhs.get_impl()) );
} }
@ -228,7 +228,7 @@ class optional_base : public optional_tag
: :
m_initialized(false) m_initialized(false)
{ {
construct(boost::forward<Expr>(expr),tag); construct(optional_detail::forward<Expr>(expr),tag);
} }
optional_base& operator= ( optional_base const& rhs ) optional_base& operator= ( optional_base const& rhs )
@ -269,13 +269,13 @@ class optional_base : public optional_tag
if (is_initialized()) if (is_initialized())
{ {
if ( rhs.is_initialized() ) if ( rhs.is_initialized() )
assign_value( boost::move(rhs.get_impl()) ); assign_value( optional_detail::move(rhs.get_impl()) );
else destroy(); else destroy();
} }
else else
{ {
if ( rhs.is_initialized() ) if ( rhs.is_initialized() )
construct(boost::move(rhs.get_impl())); construct(optional_detail::move(rhs.get_impl()));
} }
} }
@ -335,8 +335,8 @@ class optional_base : public optional_tag
void assign ( rval_reference_type val ) void assign ( rval_reference_type val )
{ {
if (is_initialized()) if (is_initialized())
assign_value( boost::move(val) ); assign_value( optional_detail::move(val) );
else construct( boost::move(val) ); else construct( optional_detail::move(val) );
} }
// Assigns from "none", destroying the current value, if any, leaving this UNINITIALIZED // Assigns from "none", destroying the current value, if any, leaving this UNINITIALIZED
@ -349,8 +349,8 @@ class optional_base : public optional_tag
void assign_expr ( Expr&& expr, ExprPtr const* tag ) void assign_expr ( Expr&& expr, ExprPtr const* tag )
{ {
if (is_initialized()) if (is_initialized())
assign_expr_to_initialized(boost::forward<Expr>(expr),tag); assign_expr_to_initialized(optional_detail::forward<Expr>(expr),tag);
else construct(boost::forward<Expr>(expr),tag); else construct(optional_detail::forward<Expr>(expr),tag);
} }
#endif #endif
@ -382,7 +382,7 @@ class optional_base : public optional_tag
void construct ( rval_reference_type val ) void construct ( rval_reference_type val )
{ {
::new (m_storage.address()) unqualified_value_type( boost::move(val) ) ; ::new (m_storage.address()) unqualified_value_type( optional_detail::move(val) ) ;
m_initialized = true ; m_initialized = true ;
} }
@ -392,7 +392,7 @@ class optional_base : public optional_tag
template<class... Args> template<class... Args>
void construct ( in_place_init_t, Args&&... args ) void construct ( in_place_init_t, Args&&... args )
{ {
::new (m_storage.address()) unqualified_value_type( boost::forward<Args>(args)... ) ; ::new (m_storage.address()) unqualified_value_type( optional_detail::forward<Args>(args)... ) ;
m_initialized = true ; m_initialized = true ;
} }
@ -400,7 +400,7 @@ class optional_base : public optional_tag
void emplace_assign ( Args&&... args ) void emplace_assign ( Args&&... args )
{ {
destroy(); destroy();
construct(in_place_init, boost::forward<Args>(args)...); construct(in_place_init, optional_detail::forward<Args>(args)...);
} }
template<class... Args> template<class... Args>
@ -408,7 +408,7 @@ class optional_base : public optional_tag
: :
m_initialized(false) m_initialized(false)
{ {
construct(in_place_init, boost::forward<Args>(args)...); construct(in_place_init, optional_detail::forward<Args>(args)...);
} }
template<class... Args> template<class... Args>
@ -417,7 +417,7 @@ class optional_base : public optional_tag
m_initialized(false) m_initialized(false)
{ {
if ( cond ) if ( cond )
construct(in_place_init, boost::forward<Args>(args)...); construct(in_place_init, optional_detail::forward<Args>(args)...);
} }
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
@ -462,7 +462,7 @@ class optional_base : public optional_tag
template<class Expr> template<class Expr>
void construct ( Expr&& expr, void const* ) void construct ( Expr&& expr, void const* )
{ {
new (m_storage.address()) unqualified_value_type(boost::forward<Expr>(expr)) ; new (m_storage.address()) unqualified_value_type(optional_detail::forward<Expr>(expr)) ;
m_initialized = true ; m_initialized = true ;
} }
@ -473,7 +473,7 @@ class optional_base : public optional_tag
template<class Expr> template<class Expr>
void assign_expr_to_initialized ( Expr&& expr, void const* ) void assign_expr_to_initialized ( Expr&& expr, void const* )
{ {
assign_value( boost::forward<Expr>(expr) ); assign_value( optional_detail::forward<Expr>(expr) );
} }
#ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION #ifdef BOOST_OPTIONAL_WEAK_OVERLOAD_RESOLUTION
@ -498,7 +498,7 @@ class optional_base : public optional_tag
{ {
// An exception can be thrown here. // An exception can be thrown here.
// It it happens, THIS will be left uninitialized. // It it happens, THIS will be left uninitialized.
new (m_storage.address()) unqualified_value_type(boost::move(expr.get())) ; new (m_storage.address()) unqualified_value_type(optional_detail::move(expr.get())) ;
m_initialized = true ; m_initialized = true ;
} }
} }
@ -686,7 +686,7 @@ class optional
// Creates an optional<T> initialized with 'move(val)'. // Creates an optional<T> initialized with 'move(val)'.
// Can throw if T::T(T &&) does // Can throw if T::T(T &&) does
optional ( rval_reference_type val ) : base(optional_detail::init_value_tag(), boost::forward<T>(val)) optional ( rval_reference_type val ) : base(optional_detail::init_value_tag(), optional_detail::forward<T>(val))
{} {}
// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional. // Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional.
@ -695,7 +695,7 @@ class optional
/// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional. /// Creates an optional<T> initialized with 'val' IFF cond is true, otherwise creates an uninitialized optional.
// Can throw if T::T(T &&) does // 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, optional_detail::forward<T>(val) )
{} {}
// NOTE: MSVC needs templated versions first // NOTE: MSVC needs templated versions first
@ -729,7 +729,7 @@ class optional
base() base()
{ {
if ( rhs.is_initialized() ) if ( rhs.is_initialized() )
this->construct( boost::move(rhs.get()) ); this->construct( optional_detail::move(rhs.get()) );
} }
#ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #ifndef BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
@ -748,7 +748,7 @@ class optional
explicit optional ( Expr&& expr, explicit optional ( Expr&& expr,
BOOST_DEDUCED_TYPENAME boost::enable_if< optional_detail::is_optional_val_init_candidate<T, Expr>, bool>::type = true 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)) : base(optional_detail::forward<Expr>(expr),boost::addressof(expr))
{} {}
#endif // !defined BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT #endif // !defined BOOST_OPTIONAL_NO_INPLACE_FACTORY_SUPPORT
@ -768,7 +768,7 @@ class optional
#else #else
optional ( optional && rhs ) optional ( optional && rhs )
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value) BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value)
: base( boost::move(rhs) ) : base( optional_detail::move(rhs) )
{} {}
#endif #endif
@ -787,7 +787,7 @@ class optional
BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_assign_candidate<T, Expr>, optional&>::type BOOST_DEDUCED_TYPENAME boost::enable_if<optional_detail::is_optional_val_assign_candidate<T, Expr>, optional&>::type
operator= ( Expr&& expr ) operator= ( Expr&& expr )
{ {
this->assign_expr(boost::forward<Expr>(expr),boost::addressof(expr)); this->assign_expr(optional_detail::forward<Expr>(expr),boost::addressof(expr));
return *this ; return *this ;
} }
@ -809,7 +809,7 @@ class optional
template<class U> template<class U>
optional& operator= ( optional<U> && rhs ) optional& operator= ( optional<U> && rhs )
{ {
this->assign(boost::move(rhs)); this->assign(optional_detail::move(rhs));
return *this ; return *this ;
} }
@ -845,7 +845,7 @@ class optional
BOOST_DEDUCED_TYPENAME boost::enable_if<boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<T_>::type>, optional&>::type BOOST_DEDUCED_TYPENAME boost::enable_if<boost::is_same<T, BOOST_DEDUCED_TYPENAME boost::decay<T_>::type>, optional&>::type
operator= ( T_&& val ) operator= ( T_&& val )
{ {
this->assign( boost::forward<T_>(val) ) ; this->assign( optional_detail::forward<T_>(val) ) ;
return *this ; return *this ;
} }
@ -862,7 +862,7 @@ class optional
// Assigns from a T (deep-moves the rhs value) // Assigns from a T (deep-moves the rhs value)
optional& operator= ( rval_reference_type val ) optional& operator= ( rval_reference_type val )
{ {
this->assign( boost::move(val) ) ; this->assign( optional_detail::move(val) ) ;
return *this ; return *this ;
} }
@ -882,17 +882,17 @@ class optional
template<class... Args> template<class... Args>
void emplace ( Args&&... args ) void emplace ( Args&&... args )
{ {
this->emplace_assign( boost::forward<Args>(args)... ); this->emplace_assign( optional_detail::forward<Args>(args)... );
} }
template<class... Args> template<class... Args>
explicit optional ( in_place_init_t, Args&&... args ) explicit optional ( in_place_init_t, Args&&... args )
: base( in_place_init, boost::forward<Args>(args)... ) : base( in_place_init, optional_detail::forward<Args>(args)... )
{} {}
template<class... Args> template<class... Args>
explicit optional ( in_place_init_if_t, bool cond, Args&&... args ) explicit optional ( in_place_init_if_t, bool cond, Args&&... args )
: base( in_place_init_if, cond, boost::forward<Args>(args)... ) : base( in_place_init_if, cond, optional_detail::forward<Args>(args)... )
{} {}
void swap( optional & arg ) void swap( optional & arg )
@ -924,7 +924,7 @@ class optional
// No-throw // No-throw
reference_const_type operator *() const& { return this->get() ; } reference_const_type operator *() const& { return this->get() ; }
reference_type operator *() & { return this->get() ; } reference_type operator *() & { return this->get() ; }
reference_type_of_temporary_wrapper operator *() && { return boost::move(this->get()) ; } reference_type_of_temporary_wrapper operator *() && { return optional_detail::move(this->get()) ; }
reference_const_type value() const& reference_const_type value() const&
{ {
@ -945,7 +945,7 @@ class optional
reference_type_of_temporary_wrapper value() && reference_type_of_temporary_wrapper value() &&
{ {
if (this->is_initialized()) if (this->is_initialized())
return boost::move(this->get()) ; return optional_detail::move(this->get()) ;
else else
throw_exception(bad_optional_access()); throw_exception(bad_optional_access());
} }
@ -958,16 +958,16 @@ class optional
if (this->is_initialized()) if (this->is_initialized())
return get(); return get();
else else
return boost::forward<U>(v); return optional_detail::forward<U>(v);
} }
template <class U> template <class U>
value_type value_or ( U&& v ) && value_type value_or ( U&& v ) &&
{ {
if (this->is_initialized()) if (this->is_initialized())
return boost::move(get()); return optional_detail::move(get());
else else
return boost::forward<U>(v); return optional_detail::forward<U>(v);
} }
template <typename F> template <typename F>
@ -983,7 +983,7 @@ class optional
value_type value_or_eval ( F f ) && value_type value_or_eval ( F f ) &&
{ {
if (this->is_initialized()) if (this->is_initialized())
return boost::move(get()); return optional_detail::move(get());
else else
return f(); return f();
} }
@ -1010,7 +1010,7 @@ class optional
optional<typename optional_detail::result_of<F, reference_type_of_temporary_wrapper>::type> map(F f) && optional<typename optional_detail::result_of<F, reference_type_of_temporary_wrapper>::type> map(F f) &&
{ {
if (this->has_value()) if (this->has_value())
return f(boost::move(this->get())); return f(optional_detail::move(this->get()));
else else
return none; return none;
} }
@ -1040,7 +1040,7 @@ class optional
flat_map(F f) && flat_map(F f) &&
{ {
if (this->has_value()) if (this->has_value())
return f(boost::move(get())); return f(optional_detail::move(get()));
else else
return none; return none;
} }
@ -1071,7 +1071,7 @@ template<class T>
inline inline
optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( T && v ) optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( T && v )
{ {
return optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>(boost::forward<T>(v)); return optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>(optional_detail::forward<T>(v));
} }
// Returns optional<T>(cond,v) // Returns optional<T>(cond,v)
@ -1079,7 +1079,7 @@ template<class T>
inline inline
optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( bool cond, T && v ) optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type> make_optional ( bool cond, T && v )
{ {
return optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>(cond,boost::forward<T>(v)); return optional<BOOST_DEDUCED_TYPENAME boost::decay<T>::type>(cond,optional_detail::forward<T>(v));
} }

View File

@ -64,7 +64,7 @@ operator>>(std::basic_istream<CharType, CharTrait>& in, optional<T>& v)
T x; T x;
in >> x; in >> x;
#ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES #ifndef BOOST_OPTIONAL_DETAIL_NO_RVALUE_REFERENCES
v = boost::move(x); v = std::move(x);
#else #else
v = x; v = x;
#endif #endif

View File

@ -240,8 +240,8 @@ void test_flat_map_move_only()
{ {
{ {
optional<MoveOnly> om (makeMoveOnly(1)), om2 (makeMoveOnly(2)); optional<MoveOnly> om (makeMoveOnly(1)), om2 (makeMoveOnly(2));
verify_type<optional<int> >(boost::move(om).flat_map(get_val)); verify_type<optional<int> >(std::move(om).flat_map(get_val));
optional<int> oi = boost::move(om2).flat_map(get_val); optional<int> oi = std::move(om2).flat_map(get_val);
BOOST_TEST(bool(oi)); BOOST_TEST(bool(oi));
BOOST_TEST_EQ(2, *oi); BOOST_TEST_EQ(2, *oi);
} }

View File

@ -62,8 +62,8 @@ int get_val(MoveOnly m)
void test_map_move_only() void test_map_move_only()
{ {
optional<MoveOnly> om (makeMoveOnly(7)), om2 (makeMoveOnly(8)); optional<MoveOnly> om (makeMoveOnly(7)), om2 (makeMoveOnly(8));
verify_type<optional<int> >(boost::move(om).map(get_val)); verify_type<optional<int> >(std::move(om).map(get_val));
optional<int> oi = boost::move(om2).map(get_val); optional<int> oi = std::move(om2).map(get_val);
BOOST_TEST(bool(oi)); BOOST_TEST(bool(oi));
BOOST_TEST_EQ(8, *oi); BOOST_TEST_EQ(8, *oi);
@ -72,7 +72,7 @@ void test_map_move_only()
BOOST_TEST_EQ(4, *oj); BOOST_TEST_EQ(4, *oj);
optional<MoveOnly> o_; optional<MoveOnly> o_;
optional<int> oi_ = boost::move(o_).map(get_val); optional<int> oi_ = std::move(o_).map(get_val);
BOOST_TEST(!oi_); BOOST_TEST(!oi_);
} }

View File

@ -82,7 +82,7 @@ void test_move_ctor_from_U()
BOOST_TEST(o2->s == sValueCopyConstructed || o2->s == sCopyConstructed || o2->s == sMoveConstructed ); BOOST_TEST(o2->s == sValueCopyConstructed || o2->s == sCopyConstructed || o2->s == sMoveConstructed );
BOOST_TEST(v1.s == sIntConstructed); BOOST_TEST(v1.s == sIntConstructed);
optional<Oracle> o3 (boost::move(v1)); optional<Oracle> o3 (std::move(v1));
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o3->s == sValueMoveConstructed || o3->s == sMoveConstructed); BOOST_TEST(o3->s == sValueMoveConstructed || o3->s == sMoveConstructed);
BOOST_TEST(v1.s == sMovedFrom); BOOST_TEST(v1.s == sMovedFrom);
@ -100,7 +100,7 @@ void test_move_ctor_form_T()
BOOST_TEST(o2->s == sCopyConstructed); BOOST_TEST(o2->s == sCopyConstructed);
BOOST_TEST(v1.s == sDefaultConstructed); BOOST_TEST(v1.s == sDefaultConstructed);
optional<Oracle> o3 (boost::move(v1)); optional<Oracle> o3 (std::move(v1));
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o3->s == sMoveConstructed); BOOST_TEST(o3->s == sMoveConstructed);
BOOST_TEST(v1.s == sMovedFrom); BOOST_TEST(v1.s == sMovedFrom);
@ -109,13 +109,13 @@ void test_move_ctor_form_T()
void test_move_ctor_from_optional_T() void test_move_ctor_from_optional_T()
{ {
optional<Oracle> o1; optional<Oracle> o1;
optional<Oracle> o2(boost::move(o1)); optional<Oracle> o2(std::move(o1));
BOOST_TEST(!o1); BOOST_TEST(!o1);
BOOST_TEST(!o2); BOOST_TEST(!o2);
optional<Oracle> o3((Oracle())); optional<Oracle> o3((Oracle()));
optional<Oracle> o4(boost::move(o3)); optional<Oracle> o4(std::move(o3));
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o4); BOOST_TEST(o4);
BOOST_TEST(o3->s == sMovedFrom); BOOST_TEST(o3->s == sMovedFrom);
@ -156,7 +156,7 @@ void test_move_assign_from_U()
BOOST_TEST(v1.s == sIntConstructed); BOOST_TEST(v1.s == sIntConstructed);
optional<Oracle> o3; optional<Oracle> o3;
o3 = boost::move(v1); o3 = std::move(v1);
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o3->s == sValueMoveConstructed); BOOST_TEST(o3->s == sValueMoveConstructed);
BOOST_TEST(v1.s == sMovedFrom); BOOST_TEST(v1.s == sMovedFrom);
@ -185,7 +185,7 @@ void test_move_assign_from_T()
BOOST_TEST(v1.s == sDefaultConstructed); BOOST_TEST(v1.s == sDefaultConstructed);
optional<Oracle> o3; optional<Oracle> o3;
o3 = boost::move(v1); o3 = std::move(v1);
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o3->s == sMoveConstructed); BOOST_TEST(o3->s == sMoveConstructed);
BOOST_TEST(v1.s == sMovedFrom); BOOST_TEST(v1.s == sMovedFrom);
@ -204,7 +204,7 @@ void test_move_assign_from_optional_T()
BOOST_TEST(o1); BOOST_TEST(o1);
BOOST_TEST(o1->s == sCopyConstructed); BOOST_TEST(o1->s == sCopyConstructed);
o2 = boost::move(o3); o2 = std::move(o3);
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o3->s == sMovedFrom); BOOST_TEST(o3->s == sMovedFrom);
BOOST_TEST(o2); BOOST_TEST(o2);
@ -236,15 +236,15 @@ void test_with_move_only()
optional<MoveOnly> o2((MoveOnly(1))); optional<MoveOnly> o2((MoveOnly(1)));
BOOST_TEST(o2); BOOST_TEST(o2);
BOOST_TEST(o2->val == 1); BOOST_TEST(o2->val == 1);
optional<MoveOnly> o3 (boost::move(o1)); optional<MoveOnly> o3 (std::move(o1));
BOOST_TEST(!o3); BOOST_TEST(!o3);
optional<MoveOnly> o4 (boost::move(o2)); optional<MoveOnly> o4 (std::move(o2));
BOOST_TEST(o4); BOOST_TEST(o4);
BOOST_TEST(o4->val == 1); BOOST_TEST(o4->val == 1);
BOOST_TEST(o2); BOOST_TEST(o2);
BOOST_TEST(o2->val == 0); BOOST_TEST(o2->val == 0);
o3 = boost::move(o4); o3 = std::move(o4);
BOOST_TEST(o3); BOOST_TEST(o3);
BOOST_TEST(o3->val == 1); BOOST_TEST(o3->val == 1);
BOOST_TEST(o4); BOOST_TEST(o4);
@ -272,7 +272,7 @@ void test_move_assign_from_optional_U()
{ {
optional<MoveOnly> a((MoveOnly(2))); optional<MoveOnly> a((MoveOnly(2)));
optional<MoveOnlyB> b1; optional<MoveOnlyB> b1;
b1 = boost::move(a); b1 = std::move(a);
BOOST_TEST(b1); BOOST_TEST(b1);
BOOST_TEST(b1->val == 2); BOOST_TEST(b1->val == 2);
@ -288,7 +288,7 @@ void test_move_assign_from_optional_U()
void test_move_ctor_from_optional_U() void test_move_ctor_from_optional_U()
{ {
optional<MoveOnly> a((MoveOnly(2))); optional<MoveOnly> a((MoveOnly(2)));
optional<MoveOnlyB> b1(boost::move(a)); optional<MoveOnlyB> b1(std::move(a));
BOOST_TEST(b1); BOOST_TEST(b1);
BOOST_TEST(b1->val == 2); BOOST_TEST(b1->val == 2);
@ -323,7 +323,7 @@ void test_optional_ref_to_movables()
BOOST_TEST(m.val == 1); BOOST_TEST(m.val == 1);
BOOST_TEST(orm->val == 1); BOOST_TEST(orm->val == 1);
optional<MoveOnly&> orm3 = boost::move(orm); optional<MoveOnly&> orm3 = std::move(orm);
orm3->val = 4; orm3->val = 4;
BOOST_TEST(m.val == 4); BOOST_TEST(m.val == 4);
BOOST_TEST(orm->val == 4); BOOST_TEST(orm->val == 4);

View File

@ -89,19 +89,19 @@ void test_noexcept_optional_with_operator() // compile-time test
ONx0 onx0; ONx0 onx0;
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx2() )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx2() ));
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx2(boost::move(onx2)) )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx2(std::move(onx2)) ));
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( onx2 = ONx2() )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( onx2 = ONx2() ));
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxC() )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxC() ));
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxC(boost::move(onxC)) )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxC(std::move(onxC)) ));
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onxC = ONxC() )); BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onxC = ONxC() ));
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxA() )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONxA() ));
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( ONxA(boost::move(onxA)) )); BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( ONxA(std::move(onxA)) ));
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onxA = ONxA() )); BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onxA = ONxA() ));
BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx0() )); BOOST_STATIC_ASSERT( BOOST_NOEXCEPT_EXPR( ONx0() ));
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( ONx0(boost::move(onx0)) )); BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( ONx0(std::move(onx0)) ));
BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() )); BOOST_STATIC_ASSERT(!BOOST_NOEXCEPT_EXPR( onx0 = ONx0() ));
} }