compat3.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. // Boost.Range library
  2. //
  3. // Copyright Thorsten Ottosen 2003-2004. 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. // For more information, see http://www.boost.org/libs/range/
  9. //
  10. #include <boost/static_assert.hpp>
  11. #include <boost/type_traits.hpp>
  12. #include <boost/concept_check.hpp>
  13. #include <boost/config.hpp>
  14. enum Container {};
  15. enum String {};
  16. template< typename T >
  17. struct range_iterator;
  18. template<>
  19. struct range_iterator<Container>
  20. {
  21. template< typename C >
  22. struct pts
  23. {
  24. typedef BOOST_DEDUCED_TYPENAME C::iterator type;
  25. };
  26. };
  27. template<>
  28. struct range_iterator<String>
  29. {
  30. template< typename C >
  31. struct pts
  32. {
  33. typedef C type;
  34. };
  35. };
  36. template< typename C >
  37. class iterator_of
  38. {
  39. public:
  40. typedef BOOST_DEDUCED_TYPENAME range_iterator<Container>:: template pts<C>::type type;
  41. };
  42. #include <vector>
  43. void compat1()
  44. {
  45. std::vector<int> v;
  46. iterator_of< std::vector<int> >::type i = v.begin();
  47. boost::ignore_unused_variable_warning(i);
  48. }
  49. #include <boost/test/included/unit_test.hpp>
  50. using boost::unit_test::test_suite;
  51. test_suite* init_unit_test_suite( int argc, char* argv[] )
  52. {
  53. test_suite* test = BOOST_TEST_SUITE( "Range Test Suite" );
  54. test->add( BOOST_TEST_CASE( &compat1 ) );
  55. return test;
  56. }