Switch to boost::core::invoke_swap.

boost::swap is deprecated and will be removed. Use boost::core::invoke_swap
as a replacement.
This commit is contained in:
Andrey Semashev
2023-09-03 02:20:58 +03:00
committed by Andrzej Krzemienski
parent 6266c39b8e
commit def2db7c45
3 changed files with 10 additions and 9 deletions

View File

@ -17,6 +17,7 @@
#include <boost/type_traits/is_reference.hpp> #include <boost/type_traits/is_reference.hpp>
#include <boost/type_traits/integral_constant.hpp> #include <boost/type_traits/integral_constant.hpp>
#include <boost/type_traits/conditional.hpp> #include <boost/type_traits/conditional.hpp>
#include <boost/core/invoke_swap.hpp>
namespace boost { namespace boost {
@ -894,7 +895,7 @@ class optional : public optional_detail::optional_base<T>
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value) BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
{ {
// allow for Koenig lookup // allow for Koenig lookup
boost::swap(*this, arg); boost::core::invoke_swap(*this, arg);
} }

View File

@ -13,7 +13,7 @@
#ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_SWAP_AJK_28JAN2015_HPP #ifndef BOOST_OPTIONAL_DETAIL_OPTIONAL_SWAP_AJK_28JAN2015_HPP
#define BOOST_OPTIONAL_DETAIL_OPTIONAL_SWAP_AJK_28JAN2015_HPP #define BOOST_OPTIONAL_DETAIL_OPTIONAL_SWAP_AJK_28JAN2015_HPP
#include <boost/core/swap.hpp> #include <boost/core/invoke_swap.hpp>
#include <boost/optional/optional_fwd.hpp> #include <boost/optional/optional_fwd.hpp>
namespace boost { namespace boost {
@ -39,8 +39,8 @@ struct swap_selector<true>
else if ( !hasY ) else if ( !hasY )
y.emplace(); y.emplace();
// Boost.Utility.Swap will take care of ADL and workarounds for broken compilers // Boost.Core.Swap will take care of ADL and workarounds for broken compilers
boost::swap(x.get(), y.get()); boost::core::invoke_swap(x.get(), y.get());
if( !hasX ) if( !hasX )
y = boost::none ; y = boost::none ;
@ -64,13 +64,13 @@ struct swap_selector<false>
{ {
template <class T> template <class T>
static void optional_swap ( optional<T>& x, optional<T>& y ) static void optional_swap ( optional<T>& x, optional<T>& y )
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y))) //BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::core::invoke_swap(*x, *y)))
{ {
if (x) if (x)
{ {
if (y) if (y)
{ {
boost::swap(*x, *y); boost::core::invoke_swap(*x, *y);
} }
else else
{ {
@ -105,7 +105,7 @@ struct optional_swap_should_use_default_constructor : has_nothrow_default_constr
template <class T> template <class T>
inline void swap ( optional<T>& x, optional<T>& y ) inline void swap ( optional<T>& x, optional<T>& y )
//BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::swap(*x, *y))) //BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && BOOST_NOEXCEPT_EXPR(boost::core::invoke_swap(*x, *y)))
{ {
optional_detail::swap_selector<optional_swap_should_use_default_constructor<T>::value>::optional_swap(x, y); optional_detail::swap_selector<optional_swap_should_use_default_constructor<T>::value>::optional_swap(x, y);
} }

View File

@ -30,7 +30,7 @@
#include <boost/core/addressof.hpp> #include <boost/core/addressof.hpp>
#include <boost/core/enable_if.hpp> #include <boost/core/enable_if.hpp>
#include <boost/core/explicit_operator_bool.hpp> #include <boost/core/explicit_operator_bool.hpp>
#include <boost/core/swap.hpp> #include <boost/core/invoke_swap.hpp>
#include <boost/optional/bad_optional_access.hpp> #include <boost/optional/bad_optional_access.hpp>
#include <boost/static_assert.hpp> #include <boost/static_assert.hpp>
#include <boost/throw_exception.hpp> #include <boost/throw_exception.hpp>
@ -1260,7 +1260,7 @@ class optional
BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value) BOOST_NOEXCEPT_IF(::boost::is_nothrow_move_constructible<T>::value && ::boost::is_nothrow_move_assignable<T>::value)
{ {
// allow for Koenig lookup // allow for Koenig lookup
boost::swap(*this, arg); boost::core::invoke_swap(*this, arg);
} }