| 1 | // Boost.Range library |
| 2 | // |
| 3 | // Copyright Neil Groves 2014. Use, modification and |
| 4 | // distribution is subject to the Boost Software License, Version |
| 5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
| 6 | // http://www.boost.org/LICENSE_1_0.txt) |
| 7 | // |
| 8 | #include <boost/range/adaptor/type_erased.hpp> |
| 9 | #include "type_erased_test.hpp" |
| 10 | |
| 11 | #include <boost/test/unit_test.hpp> |
| 12 | |
| 13 | #include <algorithm> |
| 14 | #include <vector> |
| 15 | |
| 16 | namespace boost_range_adaptor_type_erased_test |
| 17 | { |
| 18 | namespace |
| 19 | { |
| 20 | |
| 21 | void template_parameter_conversion() |
| 22 | { |
| 23 | typedef boost::any_range< |
| 24 | int |
| 25 | , boost::random_access_traversal_tag |
| 26 | , int& |
| 27 | , std::ptrdiff_t |
| 28 | > source_range_type; |
| 29 | |
| 30 | typedef boost::any_range< |
| 31 | int |
| 32 | , boost::single_pass_traversal_tag |
| 33 | , const int& |
| 34 | , std::ptrdiff_t |
| 35 | > target_range_type; |
| 36 | |
| 37 | source_range_type source; |
| 38 | |
| 39 | // Converting via construction |
| 40 | target_range_type t1(source); |
| 41 | |
| 42 | // Converting via assignment |
| 43 | target_range_type t2; |
| 44 | t2 = source; |
| 45 | |
| 46 | // Converting via construction to a type with a reference type |
| 47 | // that is a value |
| 48 | typedef boost::any_range< |
| 49 | int |
| 50 | , boost::single_pass_traversal_tag |
| 51 | , int |
| 52 | , std::ptrdiff_t |
| 53 | > target_range2_type; |
| 54 | |
| 55 | target_range2_type t3(source); |
| 56 | target_range2_type t4; |
| 57 | t4 = source; |
| 58 | } |
| 59 | |
| 60 | } // anonymous namespace |
| 61 | } // namespace boost_range_adaptor_type_erased_test |
| 62 | |
| 63 | boost::unit_test::test_suite* |
| 64 | init_unit_test_suite(int argc, char* argv[]) |
| 65 | { |
| 66 | boost::unit_test::test_suite* test = |
| 67 | BOOST_TEST_SUITE("RangeTestSuite.adaptor.type_erased_tparam_conv" ); |
| 68 | |
| 69 | test->add(BOOST_TEST_CASE( |
| 70 | &boost_range_adaptor_type_erased_test::template_parameter_conversion)); |
| 71 | |
| 72 | return test; |
| 73 | } |
| 74 | |
| 75 | |