difference_type.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. #ifndef BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP
  11. #define BOOST_RANGE_DETAIL_DIFFERENCE_TYPE_HPP
  12. #include <boost/range/detail/common.hpp>
  13. #include <boost/iterator/iterator_traits.hpp>
  14. //////////////////////////////////////////////////////////////////////////////
  15. // missing partial specialization workaround.
  16. //////////////////////////////////////////////////////////////////////////////
  17. namespace boost
  18. {
  19. namespace range_detail
  20. {
  21. template< typename T >
  22. struct range_difference_type_;
  23. template<>
  24. struct range_difference_type_<std_container_>
  25. {
  26. template< typename C >
  27. struct pts
  28. {
  29. typedef BOOST_DEDUCED_TYPENAME C::difference_type type;
  30. };
  31. };
  32. template<>
  33. struct range_difference_type_<std_pair_>
  34. {
  35. template< typename P >
  36. struct pts
  37. {
  38. typedef BOOST_RANGE_DEDUCED_TYPENAME boost::iterator_difference< BOOST_DEDUCED_TYPENAME P::first_type>::type type;
  39. };
  40. };
  41. template<>
  42. struct range_difference_type_<array_>
  43. {
  44. template< typename A >
  45. struct pts
  46. {
  47. typedef std::ptrdiff_t type;
  48. };
  49. };
  50. template<>
  51. struct range_difference_type_<char_array_>
  52. {
  53. template< typename A >
  54. struct pts
  55. {
  56. typedef std::ptrdiff_t type;
  57. };
  58. };
  59. template<>
  60. struct range_difference_type_<char_ptr_>
  61. {
  62. template< typename S >
  63. struct pts
  64. {
  65. typedef std::ptrdiff_t type;
  66. };
  67. };
  68. template<>
  69. struct range_difference_type_<const_char_ptr_>
  70. {
  71. template< typename S >
  72. struct pts
  73. {
  74. typedef std::ptrdiff_t type;
  75. };
  76. };
  77. template<>
  78. struct range_difference_type_<wchar_t_ptr_>
  79. {
  80. template< typename S >
  81. struct pts
  82. {
  83. typedef std::ptrdiff_t type;
  84. };
  85. };
  86. template<>
  87. struct range_difference_type_<const_wchar_t_ptr_>
  88. {
  89. template< typename S >
  90. struct pts
  91. {
  92. typedef std::ptrdiff_t type;
  93. };
  94. };
  95. }
  96. template< typename C >
  97. class range_difference
  98. {
  99. typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type;
  100. public:
  101. typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range_difference_type_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type;
  102. };
  103. }
  104. #endif