specialized_in_global.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. // Copyright (c) 2007 Joseph Gauterin
  2. //
  3. // Distributed under the Boost Software License, Version 1.0.
  4. // (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. #include <boost/utility/swap.hpp>
  7. #include <boost/core/lightweight_test.hpp>
  8. #define BOOST_CHECK BOOST_TEST
  9. #define BOOST_CHECK_EQUAL BOOST_TEST_EQ
  10. //Put test class in the global namespace
  11. #include "./swap_test_class.hpp"
  12. //Provide swap function in gloabl namespace
  13. void swap(swap_test_class& left, swap_test_class& right)
  14. {
  15. left.swap(right);
  16. }
  17. int main()
  18. {
  19. const swap_test_class initial_value1(1);
  20. const swap_test_class initial_value2(2);
  21. swap_test_class object1 = initial_value1;
  22. swap_test_class object2 = initial_value2;
  23. swap_test_class::reset();
  24. boost::swap(object1,object2);
  25. BOOST_CHECK(object1 == initial_value2);
  26. BOOST_CHECK(object2 == initial_value1);
  27. BOOST_CHECK_EQUAL(swap_test_class::swap_count(),1);
  28. BOOST_CHECK_EQUAL(swap_test_class::copy_count(),0);
  29. return boost::report_errors();
  30. }