• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2008 Joseph Gauterin, Niels Dekker
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 
7 // Tests swapping std::string objects by means of boost::swap.
8 // std::string has its own std::swap overload.
9 
10 #include <boost/utility/swap.hpp>
11 #include <boost/core/lightweight_test.hpp>
12 #define BOOST_CHECK BOOST_TEST
13 #define BOOST_CHECK_EQUAL BOOST_TEST_EQ
14 
15 #include <string>
16 
main()17 int main()
18 {
19   const std::string initial_value1 = "one";
20   const std::string initial_value2 = "two";
21 
22   std::string object1 = initial_value1;
23   std::string object2 = initial_value2;
24 
25   boost::swap(object1,object2);
26 
27   BOOST_CHECK_EQUAL(object1,initial_value2);
28   BOOST_CHECK_EQUAL(object2,initial_value1);
29 
30   return boost::report_errors();
31 }
32 
33