end.hpp 3.5 KB

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