// (C) Copyright Vaclav Vesely 2006. // Use, modification and distribution are 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) #define BOOST_TEST_MAIN #include #include #include #include #include #include //----------------------------------------------------------------------------- struct X { X(int value = 0) : m_value(value), m_swapped(false) { } int m_value; bool m_swapped; }; void swap(X& left, X& right) { using std::swap; swap(left.m_value, right.m_value); left.m_swapped = right.m_swapped = true; } bool operator==(X const& left, X const& right) { return left.m_value == right.m_value; } std::ostream& operator<<(std::ostream& stream, X const& x) { stream << x.m_value; return stream; } //----------------------------------------------------------------------------- using namespace std; BOOST_AUTO_TEST_CASE(swap_test) { typedef boost::tuples::tuple tuple_type; tuple_type x(1, "1", X()); tuple_type y(2, "2", X()); tuple_type a(x); tuple_type b(y); swap(a, b); BOOST_CHECK_EQUAL(a, y); BOOST_CHECK_EQUAL(b, x); #if !defined(BOOST_NO_ARGUMENT_DEPENDENT_LOOKUP) BOOST_CHECK(boost::get<2>(a).m_swapped); BOOST_CHECK(boost::get<2>(b).m_swapped); #endif } //-----------------------------------------------------------------------------