std_bitset.cpp 947 B

12345678910111213141516171819202122232425262728293031323334
  1. // Copyright (c) 2008 - 2010 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. // Tests swapping std::bitset<T> objects by means of boost::swap.
  7. // Unlike most other Standard C++ Library template classes,
  8. // std::bitset<T> does not have its own std::swap overload.
  9. #include <boost/utility/swap.hpp>
  10. #include <boost/core/lightweight_test.hpp>
  11. #define BOOST_CHECK BOOST_TEST
  12. #define BOOST_CHECK_EQUAL BOOST_TEST_EQ
  13. #include <bitset>
  14. int main()
  15. {
  16. typedef std::bitset<8> bitset_type;
  17. const bitset_type initial_value1 = 1;
  18. const bitset_type initial_value2 = 2;
  19. bitset_type object1 = initial_value1;
  20. bitset_type object2 = initial_value2;
  21. boost::swap(object1,object2);
  22. BOOST_CHECK_EQUAL(object1,initial_value2);
  23. BOOST_CHECK_EQUAL(object2,initial_value1);
  24. return boost::report_errors();
  25. }