end.hpp 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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_END_HPP
  11. #define BOOST_RANGE_DETAIL_END_HPP
  12. #include <boost/config.hpp> // BOOST_MSVC
  13. #include <boost/detail/workaround.hpp>
  14. #if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  15. # include <boost/range/detail/vc6/end.hpp>
  16. #else
  17. # include <boost/range/detail/implementation_help.hpp>
  18. # include <boost/range/iterator.hpp>
  19. # include <boost/range/detail/common.hpp>
  20. # if BOOST_WORKAROUND(BOOST_MSVC, < 1310)
  21. # include <boost/range/detail/remove_extent.hpp>
  22. # endif
  23. namespace boost
  24. {
  25. namespace range_detail
  26. {
  27. template< typename T >
  28. struct range_end;
  29. //////////////////////////////////////////////////////////////////////
  30. // default
  31. //////////////////////////////////////////////////////////////////////
  32. template<>
  33. struct range_end<std_container_>
  34. {
  35. template< typename C >
  36. static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
  37. fun( C& c )
  38. {
  39. return c.end();
  40. };
  41. };
  42. //////////////////////////////////////////////////////////////////////
  43. // pair
  44. //////////////////////////////////////////////////////////////////////
  45. template<>
  46. struct range_end<std_pair_>
  47. {
  48. template< typename P >
  49. static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
  50. fun( const P& p )
  51. {
  52. return p.second;
  53. }
  54. };
  55. //////////////////////////////////////////////////////////////////////
  56. // array
  57. //////////////////////////////////////////////////////////////////////
  58. template<>
  59. struct range_end<array_>
  60. {
  61. #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
  62. template< typename T, std::size_t sz >
  63. static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] )
  64. {
  65. return boost::range_detail::array_end( boost_range_array );
  66. }
  67. #else
  68. template<typename T>
  69. static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
  70. {
  71. return t + remove_extent<T>::size;
  72. }
  73. #endif
  74. };
  75. } // namespace 'range_detail'
  76. namespace range_adl_barrier
  77. {
  78. template< typename C >
  79. inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
  80. end( C& c )
  81. {
  82. return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
  83. }
  84. } // namespace range_adl_barrier
  85. } // namespace 'boost'
  86. # endif // VC6
  87. #endif