2
0
mirror of https://github.com/boostorg/core.git synced 2026-01-19 04:02:18 +00:00
Files
core/test/swap/swap_const_wrapper_fail.cpp
Andrey Semashev 9fc2a2f1ac Renamed boost::swap to boost::core::invoke_swap, deprecated boost::swap.
The rename allows to avoid forming an infinite recursion in compile time
(because of noexcept specification that needs to resolve the unqualified call
to swap) or run time (in case if the boost::swap function is the only one
suitable for the passed arguments).

To avoid the compile-time recursion, removed noexcept specification from
boost::swap. The specification is still present in boost::core::invoke_swap.

Deprecated boost::swap and associated headers. boost::core::invoke_swap
is defined in a new boost/core/invoke_swap.hpp header.

Updated docs and tests. Removed tests that check inclusion of deprecated
headers.

Fixes https://github.com/boostorg/core/issues/148.
2023-07-12 12:17:07 +03:00

29 lines
492 B
C++

// Copyright 2018 Andrzej Krzemieński
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
#include <boost/core/invoke_swap.hpp>
namespace boost
{
template<class T> struct Wrapper
{
T value;
};
template<class T> inline void swap( Wrapper<T> & w, Wrapper<T> & v )
{
boost::core::invoke_swap( w, v );
}
} // namespace boost
int main()
{
boost::Wrapper<int> const w = { 2 };
boost::Wrapper<int> const v = { 3 };
swap( w, v );
}