end.hpp 3.7 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)
  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. #include <boost/config.hpp>
  23. #include <boost/config/workaround.hpp>
  24. namespace boost
  25. {
  26. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  27. namespace range_detail
  28. {
  29. #endif
  30. //////////////////////////////////////////////////////////////////////
  31. // primary template
  32. //////////////////////////////////////////////////////////////////////
  33. template< typename C >
  34. BOOST_CONSTEXPR 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. BOOST_CONSTEXPR inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
  49. {
  50. return p.second;
  51. }
  52. template< typename Iterator >
  53. BOOST_CONSTEXPR 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. BOOST_CONSTEXPR inline const T* range_end( const T (&a)[sz] ) BOOST_NOEXCEPT
  62. {
  63. return range_detail::array_end<T,sz>( a );
  64. }
  65. template< typename T, std::size_t sz >
  66. BOOST_CONSTEXPR inline T* range_end( T (&a)[sz] ) BOOST_NOEXCEPT
  67. {
  68. return range_detail::array_end<T,sz>( a );
  69. }
  70. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  71. } // namespace 'range_detail'
  72. #endif
  73. namespace range_adl_barrier
  74. {
  75. template< class T >
  76. #if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
  77. BOOST_CONSTEXPR
  78. #endif
  79. inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
  80. {
  81. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  82. using namespace range_detail;
  83. #endif
  84. return range_end( r );
  85. }
  86. template< class T >
  87. #if !BOOST_WORKAROUND(BOOST_GCC, < 40700)
  88. BOOST_CONSTEXPR
  89. #endif
  90. inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
  91. {
  92. #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
  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. BOOST_CONSTEXPR 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