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_DETAIL_END_HPP |
---|
12 | #define BOOST_RANGE_DETAIL_END_HPP |
---|
13 | |
---|
14 | #include <boost/config.hpp> // BOOST_MSVC |
---|
15 | #include <boost/detail/workaround.hpp> |
---|
16 | |
---|
17 | #if BOOST_WORKAROUND(BOOST_MSVC, < 1300) |
---|
18 | # include <boost/range/detail/vc6/end.hpp> |
---|
19 | #else |
---|
20 | # include <boost/range/detail/implementation_help.hpp> |
---|
21 | # include <boost/range/iterator.hpp> |
---|
22 | # include <boost/range/detail/common.hpp> |
---|
23 | # if BOOST_WORKAROUND(BOOST_MSVC, < 1310) |
---|
24 | # include <boost/range/detail/remove_extent.hpp> |
---|
25 | # endif |
---|
26 | |
---|
27 | namespace boost |
---|
28 | { |
---|
29 | namespace range_detail |
---|
30 | { |
---|
31 | template< typename T > |
---|
32 | struct range_end; |
---|
33 | |
---|
34 | ////////////////////////////////////////////////////////////////////// |
---|
35 | // default |
---|
36 | ////////////////////////////////////////////////////////////////////// |
---|
37 | |
---|
38 | template<> |
---|
39 | struct range_end<std_container_> |
---|
40 | { |
---|
41 | template< typename C > |
---|
42 | static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type |
---|
43 | fun( C& c ) |
---|
44 | { |
---|
45 | return c.end(); |
---|
46 | }; |
---|
47 | }; |
---|
48 | |
---|
49 | ////////////////////////////////////////////////////////////////////// |
---|
50 | // pair |
---|
51 | ////////////////////////////////////////////////////////////////////// |
---|
52 | |
---|
53 | template<> |
---|
54 | struct range_end<std_pair_> |
---|
55 | { |
---|
56 | template< typename P > |
---|
57 | static BOOST_RANGE_DEDUCED_TYPENAME range_iterator<P>::type |
---|
58 | fun( const P& p ) |
---|
59 | { |
---|
60 | return p.second; |
---|
61 | } |
---|
62 | }; |
---|
63 | |
---|
64 | ////////////////////////////////////////////////////////////////////// |
---|
65 | // array |
---|
66 | ////////////////////////////////////////////////////////////////////// |
---|
67 | |
---|
68 | template<> |
---|
69 | struct range_end<array_> |
---|
70 | { |
---|
71 | #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) |
---|
72 | template< typename T, std::size_t sz > |
---|
73 | static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) |
---|
74 | { |
---|
75 | return boost::range_detail::array_end( boost_range_array ); |
---|
76 | } |
---|
77 | #else |
---|
78 | template<typename T> |
---|
79 | static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t) |
---|
80 | { |
---|
81 | return t + remove_extent<T>::size; |
---|
82 | } |
---|
83 | #endif |
---|
84 | }; |
---|
85 | |
---|
86 | } // namespace 'range_detail' |
---|
87 | |
---|
88 | template< typename C > |
---|
89 | inline BOOST_RANGE_DEDUCED_TYPENAME range_iterator<C>::type |
---|
90 | end( C& c ) |
---|
91 | { |
---|
92 | return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c ); |
---|
93 | } |
---|
94 | |
---|
95 | } // namespace 'boost' |
---|
96 | |
---|
97 | # endif // VC6 |
---|
98 | #endif |
---|