mirror of
https://github.com/boostorg/core.git
synced 2025-11-30 14:19:38 +01:00
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.
This commit is contained in:
@@ -4,9 +4,9 @@
|
||||
// (See accompanying file LICENSE_1_0.txt or copy at
|
||||
// http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
// Tests that boost::swap propagates noexcept specification correctly
|
||||
// Tests that boost::core::invoke_swap propagates noexcept specification correctly
|
||||
|
||||
#include <boost/core/swap.hpp>
|
||||
#include <boost/core/invoke_swap.hpp>
|
||||
#include <boost/config.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) && \
|
||||
@@ -34,9 +34,9 @@ struct class_with_except_swap
|
||||
|
||||
} // namespace test_ns
|
||||
|
||||
static_assert(noexcept(boost::swap(test_ns::class_with_noexcept_swap::instance(), test_ns::class_with_noexcept_swap::instance())),
|
||||
"boost::swap for class_with_noexcept_swap should have noexcept specification");
|
||||
static_assert(!noexcept(boost::swap(test_ns::class_with_except_swap::instance(), test_ns::class_with_except_swap::instance())),
|
||||
"boost::swap for class_with_except_swap should not have noexcept specification");
|
||||
static_assert(noexcept(boost::core::invoke_swap(test_ns::class_with_noexcept_swap::instance(), test_ns::class_with_noexcept_swap::instance())),
|
||||
"boost::core::invoke_swap for class_with_noexcept_swap should have noexcept specification");
|
||||
static_assert(!noexcept(boost::core::invoke_swap(test_ns::class_with_except_swap::instance(), test_ns::class_with_except_swap::instance())),
|
||||
"boost::core::invoke_swap for class_with_except_swap should not have noexcept specification");
|
||||
|
||||
#endif // !defined(BOOST_NO_CXX11_NOEXCEPT) && !defined(BOOST_NO_CXX11_STATIC_ASSERT) ...
|
||||
|
||||
Reference in New Issue
Block a user