end.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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. namespace range_adl_barrier
  76. {
  77. template< class T >
  78. inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
  79. {
  80. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  81. !BOOST_WORKAROUND(__GNUC__, < 3) \
  82. /**/
  83. using namespace range_detail;
  84. #endif
  85. return range_end( r );
  86. }
  87. template< class T >
  88. inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
  89. {
  90. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564)) && \
  91. !BOOST_WORKAROUND(__GNUC__, < 3) \
  92. /**/
  93. using namespace range_detail;
  94. #endif
  95. return range_end( r );
  96. }
  97. } // namespace range_adl_barrier
  98. } // namespace 'boost'
  99. #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
  100. namespace boost
  101. {
  102. namespace range_adl_barrier
  103. {
  104. template< class T >
  105. inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
  106. const_end( const T& r )
  107. {
  108. return boost::range_adl_barrier::end( r );
  109. }
  110. } // namespace range_adl_barrier
  111. using namespace range_adl_barrier;
  112. } // namespace boost
  113. #endif