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
@@ -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,
"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
@@ -54,7 +54,7 @@ struct swap_selector<true>
#endif
#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
# define BOOST_OPTIONAL_DETAIL_MOVE(EXPR_) EXPR_
#endif
@@ -54,7 +54,7 @@ class tc_optional_base : public optional_tag
:
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;
@@ -102,7 +102,7 @@ class tc_optional_base : public optional_tag
template<class Expr, class ExprPtr>
void assign_expr ( Expr&& expr, ExprPtr const* tag )
{
construct(boost::forward<Expr>(expr),tag);
construct(optional_detail::forward<Expr>(expr),tag);
}
#endif
@@ -138,14 +138,14 @@ class tc_optional_base : public optional_tag
template<class... 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 ;
}
template<class... 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>
@@ -153,7 +153,7 @@ class tc_optional_base : public optional_tag
:
m_initialized(false)
{
construct(in_place_init, boost::forward<Args>(args)...);
construct(in_place_init, optional_detail::forward<Args>(args)...);
}
template<class... Args>
@@ -162,7 +162,7 @@ class tc_optional_base : public optional_tag
m_initialized(false)
{
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
@@ -207,7 +207,7 @@ class tc_optional_base : public optional_tag
template<class Expr>
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 ;
}
@@ -218,7 +218,7 @@ class tc_optional_base : public optional_tag
template<class Expr>
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
@@ -243,7 +243,7 @@ class tc_optional_base : public optional_tag
{
// An exception can be thrown here.
// 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 ;
}
}
@@ -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