Chris@16
|
1 // Boost.Range library
|
Chris@16
|
2 //
|
Chris@16
|
3 // Copyright Thorsten Ottosen 2003-2004. Use, modification and
|
Chris@16
|
4 // distribution is subject to the Boost Software License, Version
|
Chris@16
|
5 // 1.0. (See accompanying file LICENSE_1_0.txt or copy at
|
Chris@16
|
6 // http://www.boost.org/LICENSE_1_0.txt)
|
Chris@16
|
7 //
|
Chris@16
|
8 // For more information, see http://www.boost.org/libs/range/
|
Chris@16
|
9 //
|
Chris@16
|
10
|
Chris@16
|
11 #ifndef BOOST_RANGE_END_HPP
|
Chris@16
|
12 #define BOOST_RANGE_END_HPP
|
Chris@16
|
13
|
Chris@101
|
14 #if defined(_MSC_VER)
|
Chris@16
|
15 # pragma once
|
Chris@16
|
16 #endif
|
Chris@16
|
17
|
Chris@16
|
18 #include <boost/range/config.hpp>
|
Chris@16
|
19
|
Chris@16
|
20 #ifdef BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
Chris@16
|
21 #include <boost/range/detail/end.hpp>
|
Chris@16
|
22 #else
|
Chris@16
|
23
|
Chris@16
|
24 #include <boost/range/detail/implementation_help.hpp>
|
Chris@16
|
25 #include <boost/range/iterator.hpp>
|
Chris@16
|
26 #include <boost/range/const_iterator.hpp>
|
Chris@16
|
27
|
Chris@16
|
28 namespace boost
|
Chris@16
|
29 {
|
Chris@16
|
30
|
Chris@101
|
31 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
32 namespace range_detail
|
Chris@16
|
33 {
|
Chris@16
|
34 #endif
|
Chris@16
|
35
|
Chris@16
|
36 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
37 // primary template
|
Chris@16
|
38 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
39 template< typename C >
|
Chris@16
|
40 inline BOOST_DEDUCED_TYPENAME range_iterator<C>::type
|
Chris@16
|
41 range_end( C& c )
|
Chris@16
|
42 {
|
Chris@16
|
43 //
|
Chris@16
|
44 // If you get a compile-error here, it is most likely because
|
Chris@16
|
45 // you have not implemented range_begin() properly in
|
Chris@16
|
46 // the namespace of C
|
Chris@16
|
47 //
|
Chris@16
|
48 return c.end();
|
Chris@16
|
49 }
|
Chris@16
|
50
|
Chris@16
|
51 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
52 // pair
|
Chris@16
|
53 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
54
|
Chris@16
|
55 template< typename Iterator >
|
Chris@16
|
56 inline Iterator range_end( const std::pair<Iterator,Iterator>& p )
|
Chris@16
|
57 {
|
Chris@16
|
58 return p.second;
|
Chris@16
|
59 }
|
Chris@16
|
60
|
Chris@16
|
61 template< typename Iterator >
|
Chris@16
|
62 inline Iterator range_end( std::pair<Iterator,Iterator>& p )
|
Chris@16
|
63 {
|
Chris@16
|
64 return p.second;
|
Chris@16
|
65 }
|
Chris@16
|
66
|
Chris@16
|
67 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
68 // array
|
Chris@16
|
69 //////////////////////////////////////////////////////////////////////
|
Chris@16
|
70
|
Chris@16
|
71 template< typename T, std::size_t sz >
|
Chris@16
|
72 inline const T* range_end( const T (&a)[sz] )
|
Chris@16
|
73 {
|
Chris@16
|
74 return range_detail::array_end<T,sz>( a );
|
Chris@16
|
75 }
|
Chris@16
|
76
|
Chris@16
|
77 template< typename T, std::size_t sz >
|
Chris@16
|
78 inline T* range_end( T (&a)[sz] )
|
Chris@16
|
79 {
|
Chris@16
|
80 return range_detail::array_end<T,sz>( a );
|
Chris@16
|
81 }
|
Chris@16
|
82
|
Chris@101
|
83 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
84 } // namespace 'range_detail'
|
Chris@16
|
85 #endif
|
Chris@16
|
86
|
Chris@16
|
87 namespace range_adl_barrier
|
Chris@16
|
88 {
|
Chris@16
|
89
|
Chris@16
|
90 template< class T >
|
Chris@16
|
91 inline BOOST_DEDUCED_TYPENAME range_iterator<T>::type end( T& r )
|
Chris@16
|
92 {
|
Chris@101
|
93 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
94 using namespace range_detail;
|
Chris@16
|
95 #endif
|
Chris@16
|
96 return range_end( r );
|
Chris@16
|
97 }
|
Chris@16
|
98
|
Chris@16
|
99 template< class T >
|
Chris@16
|
100 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type end( const T& r )
|
Chris@16
|
101 {
|
Chris@101
|
102 #if !BOOST_WORKAROUND(__BORLANDC__, BOOST_TESTED_AT(0x564))
|
Chris@16
|
103 using namespace range_detail;
|
Chris@16
|
104 #endif
|
Chris@16
|
105 return range_end( r );
|
Chris@16
|
106 }
|
Chris@16
|
107
|
Chris@16
|
108 } // namespace range_adl_barrier
|
Chris@16
|
109 } // namespace 'boost'
|
Chris@16
|
110
|
Chris@16
|
111 #endif // BOOST_NO_FUNCTION_TEMPLATE_ORDERING
|
Chris@16
|
112
|
Chris@16
|
113 namespace boost
|
Chris@16
|
114 {
|
Chris@16
|
115 namespace range_adl_barrier
|
Chris@16
|
116 {
|
Chris@16
|
117 template< class T >
|
Chris@16
|
118 inline BOOST_DEDUCED_TYPENAME range_iterator<const T>::type
|
Chris@16
|
119 const_end( const T& r )
|
Chris@16
|
120 {
|
Chris@16
|
121 return boost::range_adl_barrier::end( r );
|
Chris@16
|
122 }
|
Chris@16
|
123 } // namespace range_adl_barrier
|
Chris@16
|
124 using namespace range_adl_barrier;
|
Chris@16
|
125 } // namespace boost
|
Chris@16
|
126
|
Chris@16
|
127 #endif
|
Chris@16
|
128
|