end.hpp 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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_END_HPP
  11. #define BOOST_RANGE_END_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif
  15. #include <boost/range/config.hpp>
  16. #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  17. #include <boost/range/detail/end.hpp>
  18. #else
  19. #include <boost/range/detail/implementation_help.hpp>
  20. #include <boost/range/iterator.hpp>
  21. #include <boost/range/const_iterator.hpp>
  22. namespace boost
  23. {
  24. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  25. !BOOST_WORKAROUND(__GNUC__, < 3) \
  26. /**/
  27. namespace range_detail
  28. {
  29. #endif
  30. //////////////////////////////////////////////////////////////////////
  31. // primary template
  32. //////////////////////////////////////////////////////////////////////
  33. template< typename C >
  34. inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
  35. range_end( C& c )
  36. {
  37. //
  38. // If you get a compile-error here, it is most likely because
  39. // you have not implemented range_begin() properly in
  40. // the namespace of C
  41. //
  42. return c.end();
  43. }
  44. //////////////////////////////////////////////////////////////////////
  45. // pair
  46. //////////////////////////////////////////////////////////////////////
  47. template< typename Iterator >
  48. inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
  49. {
  50. return p.second;
  51. }
  52. template< typename Iterator >
  53. inline Iterator range_end( std::pair<Iterator,Iterator>& p )
  54. {
  55. return p.second;
  56. }
  57. //////////////////////////////////////////////////////////////////////
  58. // array
  59. //////////////////////////////////////////////////////////////////////
  60. template< typename T, std::size_t sz >
  61. inline const T* range_end( const T (&a)[sz] )
  62. {
  63. return range_detail::array_end<T,sz>( a );
  64. }
  65. template< typename T, std::size_t sz >
  66. inline T* range_end( T (&a)[sz] )
  67. {
  68. return range_detail::array_end<T,sz>( a );
  69. }
  70. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  71. !BOOST_WORKAROUND(__GNUC__, < 3) \
  72. /**/
  73. } // namespace 'range_detail'
  74. #endif
  75. template< class T >
  76. inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
  77. {
  78. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  79. !BOOST_WORKAROUND(__GNUC__, < 3) \
  80. /**/
  81. using namespace range_detail;
  82. #endif
  83. return range_end( r );
  84. }
  85. template< class T >
  86. inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
  87. {
  88. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  89. !BOOST_WORKAROUND(__GNUC__, < 3) \
  90. /**/
  91. using namespace range_detail;
  92. #endif
  93. return range_end( r );
  94. }
  95. } // namespace 'boost'
  96. #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  97. namespace boost
  98. {
  99. template< class T >
  100. inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
  101. const_end( const T& r )
  102. {
  103. return boost::end( r );
  104. }
  105. }
  106. #endif