| 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::type_info pointers by means of boost::core::invoke_swap. |
| 8 | // There is no std::swap overload or template specialization |
| 9 | // for std::type_info pointers. |
| 10 | |
| 11 | #include <boost/core/invoke_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 <typeinfo> |
| 17 | |
| 18 | int main() |
| 19 | { |
| 20 | const std::type_info * const initial_value1 = 0; |
| 21 | const std::type_info * const initial_value2 = &typeid(double); |
| 22 | |
| 23 | const std::type_info * ptr1 = initial_value1; |
| 24 | const std::type_info * ptr2 = initial_value2; |
| 25 | |
| 26 | boost::core::invoke_swap(left&: ptr1,right&: ptr2); |
| 27 | |
| 28 | BOOST_CHECK_EQUAL(ptr1,initial_value2); |
| 29 | BOOST_CHECK_EQUAL(ptr2,initial_value1); |
| 30 | |
| 31 | return boost::report_errors(); |
| 32 | } |
| 33 | |
| 34 |
