end.hpp 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. #include <boost/range/detail/implementation_help.hpp>
  15. #include <boost/range/iterator.hpp>
  16. #include <boost/range/detail/common.hpp>
  17. namespace boost
  18. {
  19. namespace range_detail
  20. {
  21. template< typename T >
  22. struct range_end;
  23. //////////////////////////////////////////////////////////////////////
  24. // default
  25. //////////////////////////////////////////////////////////////////////
  26. template<>
  27. struct range_end<std_container_>
  28. {
  29. template< typename C >
  30. BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
  31. fun( C& c )
  32. {
  33. return c.end();
  34. };
  35. };
  36. //////////////////////////////////////////////////////////////////////
  37. // pair
  38. //////////////////////////////////////////////////////////////////////
  39. template<>
  40. struct range_end<std_pair_>
  41. {
  42. template< typename P >
  43. BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type
  44. fun( const P& p )
  45. {
  46. return p.second;
  47. }
  48. };
  49. //////////////////////////////////////////////////////////////////////
  50. // array
  51. //////////////////////////////////////////////////////////////////////
  52. template<>
  53. struct range_end<array_>
  54. {
  55. template<typename T>
  56. BOOST_CONSTEXPR static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t)
  57. {
  58. return t + remove_extent<T>::size;
  59. }
  60. };
  61. } // namespace 'range_detail'
  62. namespace range_adl_barrier
  63. {
  64. template< typename C >
  65. BOOST_CONSTEXPR inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type
  66. end( C& c )
  67. {
  68. return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c );
  69. }
  70. } // namespace range_adl_barrier
  71. } // namespace 'boost'
  72. #endif