mirror of
https://github.com/boostorg/utility.git
synced 2025-05-09 02:44:10 +00:00
Added specialized_in_boost_and_other to swap/test, as discussed at "[boost] [swap] End-user allowed to add overloads to boost namespace?", http://lists.boost.org/Archives/boost/2008/07/140327.php
[SVN r47839]
This commit is contained in:
parent
b050431638
commit
3fd0ea6e75
@ -15,11 +15,12 @@ test-suite utility/swap
|
||||
[ compile lib_header_2.cpp ]
|
||||
[ compile mixed_headers_1.cpp ]
|
||||
[ compile mixed_headers_2.cpp ]
|
||||
[ run primitive.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run primitive.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_boost.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_global.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_std.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run specialized_in_boost_and_other.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run test_adl_barrier.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
[ run swap_arrays.cpp ../../../test/build//boost_test_exec_monitor/<link>static ]
|
||||
;
|
||||
|
56
swap/test/specialized_in_boost_and_other.cpp
Normal file
56
swap/test/specialized_in_boost_and_other.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (c) 2008 Joseph Gauterin, Niels Dekker
|
||||
//
|
||||
// Distributed under 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)
|
||||
|
||||
// Tests whether two object in a namespace other than boost are properly
|
||||
// swapped, when both boost and the other namespace have a custom swap function
|
||||
// for their class. Note that it shouldn't be necessary for a class in an other
|
||||
// namespace to have a custom swap function in boost, because the boost::swap
|
||||
// utility should find the swap function in the other namespace, by argument
|
||||
// dependent lookup (ADL). Unfortunately ADL isn't fully implemented by some
|
||||
// specific compilers, including Intel C++ 8.1, MSVC 7.1, and Borland 5.9.3.
|
||||
// Users of those compilers might consider adding a swap overload to the boost
|
||||
// namespace.
|
||||
|
||||
#include <boost/utility/swap.hpp>
|
||||
#define BOOST_INCLUDE_MAIN
|
||||
#include <boost/test/test_tools.hpp>
|
||||
|
||||
//Put test class in namespace other
|
||||
namespace other
|
||||
{
|
||||
#include "./swap_test_class.hpp"
|
||||
}
|
||||
|
||||
//Provide swap function in namespace boost
|
||||
namespace boost
|
||||
{
|
||||
void swap(::other::swap_test_class& left, ::other::swap_test_class& right)
|
||||
{
|
||||
left.swap(right);
|
||||
}
|
||||
}
|
||||
|
||||
//Provide swap function in namespace other
|
||||
namespace other
|
||||
{
|
||||
void swap(swap_test_class& left, swap_test_class& right)
|
||||
{
|
||||
left.swap(right);
|
||||
}
|
||||
}
|
||||
|
||||
int test_main(int, char*[])
|
||||
{
|
||||
other::swap_test_class object1;
|
||||
other::swap_test_class object2;
|
||||
boost::swap(object1,object2);
|
||||
|
||||
BOOST_CHECK_EQUAL(other::swap_test_class::swap_count(),1);
|
||||
BOOST_CHECK_EQUAL(other::swap_test_class::copy_count(),0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user