end.hpp 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. template< typename C >
  77. inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
  78. end( C& c )
  79. {
  80. return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
  81. }
  82. } // namespace 'boost'
  83. # endif // VC6
  84. #endif