end.hpp 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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_VC6_END_HPP
  11. #define BOOST_RANGE_DETAIL_VC6_END_HPP
  12. #include <boost/range/detail/implementation_help.hpp>
  13. #include <boost/range/detail/implementation_help.hpp>
  14. #include <boost/range/result_iterator.hpp>
  15. #include <boost/range/detail/common.hpp>
  16. #include <boost/range/detail/remove_extent.hpp>
  17. namespace boost
  18. {
  19. namespace range_detail
  20. {
  21. template< typename T >
  22. struct range_end;
  23. //////////////////////////////////////////////////////////////////////
  24. // default
  25. //////////////////////////////////////////////////////////////////////
  26. template<>
  27. struct range_end<std_container_>
  28. {
  29. template< typename C >
  30. struct inner {
  31. static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type
  32. fun( C& c )
  33. {
  34. return c.end();
  35. };
  36. };
  37. };
  38. //////////////////////////////////////////////////////////////////////
  39. // pair
  40. //////////////////////////////////////////////////////////////////////
  41. template<>
  42. struct range_end<std_pair_>
  43. {
  44. template< typename P >
  45. struct inner {
  46. static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type
  47. fun( const P& p )
  48. {
  49. return p.second;
  50. }
  51. };
  52. };
  53. //////////////////////////////////////////////////////////////////////
  54. // array
  55. //////////////////////////////////////////////////////////////////////
  56. template<>
  57. struct range_end<array_>
  58. {
  59. template< typename T >
  60. struct inner {
  61. static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
  62. fun(T& t)
  63. {
  64. return t + remove_extent<T>::size;
  65. }
  66. };
  67. };
  68. template<>
  69. struct range_end<char_array_>
  70. {
  71. template< typename T >
  72. struct inner {
  73. static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
  74. fun(T& t)
  75. {
  76. return t + remove_extent<T>::size;
  77. }
  78. };
  79. };
  80. template<>
  81. struct range_end<wchar_t_array_>
  82. {
  83. template< typename T >
  84. struct inner {
  85. static BOOST_DEDUCED_TYPENAME remove_extent<T>::type*
  86. fun(T& t)
  87. {
  88. return t + remove_extent<T>::size;
  89. }
  90. };
  91. };
  92. //////////////////////////////////////////////////////////////////////
  93. // string
  94. //////////////////////////////////////////////////////////////////////
  95. template<>
  96. struct range_end<char_ptr_>
  97. {
  98. template< typename T >
  99. struct inner {
  100. static char* fun( char* s )
  101. {
  102. return boost::range_detail::str_end( s );
  103. }
  104. };
  105. };
  106. template<>
  107. struct range_end<const_char_ptr_>
  108. {
  109. template< typename T >
  110. struct inner {
  111. static const char* fun( const char* s )
  112. {
  113. return boost::range_detail::str_end( s );
  114. }
  115. };
  116. };
  117. template<>
  118. struct range_end<wchar_t_ptr_>
  119. {
  120. template< typename T >
  121. struct inner {
  122. static wchar_t* fun( wchar_t* s )
  123. {
  124. return boost::range_detail::str_end( s );
  125. }
  126. };
  127. };
  128. template<>
  129. struct range_end<const_wchar_t_ptr_>
  130. {
  131. template< typename T >
  132. struct inner {
  133. static const wchar_t* fun( const wchar_t* s )
  134. {
  135. return boost::range_detail::str_end( s );
  136. }
  137. };
  138. };
  139. } // namespace 'range_detail'
  140. template< typename C >
  141. inline BOOST_DEDUCED_TYPENAME range_result_iterator<C>::type
  142. end( C& c )
  143. {
  144. return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c );
  145. }
  146. } // namespace 'boost'
  147. #endif