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