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