type_erased_tparam_conv.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. #include <boost/test/unit_test.hpp>
  11. #include <algorithm>
  12. #include <vector>
  13. namespace boost_range_adaptor_type_erased_test
  14. {
  15. namespace
  16. {
  17. void template_parameter_conversion()
  18. {
  19. typedef boost::any_range<
  20. int
  21. , boost::random_access_traversal_tag
  22. , int&
  23. , std::ptrdiff_t
  24. > source_range_type;
  25. typedef boost::any_range<
  26. int
  27. , boost::single_pass_traversal_tag
  28. , const int&
  29. , std::ptrdiff_t
  30. > target_range_type;
  31. source_range_type source;
  32. // Converting via construction
  33. target_range_type t1(source);
  34. // Converting via assignment
  35. target_range_type t2;
  36. t2 = source;
  37. // Converting via construction to a type with a reference type
  38. // that is a value
  39. typedef boost::any_range<
  40. int
  41. , boost::single_pass_traversal_tag
  42. , int
  43. , std::ptrdiff_t
  44. > target_range2_type;
  45. target_range2_type t3(source);
  46. target_range2_type t4;
  47. t4 = source;
  48. }
  49. } // anonymous namespace
  50. } // namespace boost_range_adaptor_type_erased_test
  51. boost::unit_test::test_suite*
  52. init_unit_test_suite(int argc, char* argv[])
  53. {
  54. boost::unit_test::test_suite* test =
  55. BOOST_TEST_SUITE("RangeTestSuite.adaptor.type_erased_tparam_conv");
  56. test->add(BOOST_TEST_CASE(
  57. &boost_range_adaptor_type_erased_test::template_parameter_conversion));
  58. return test;
  59. }