[12] | 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/detail/implementation_help.hpp> |
---|
| 22 | # include <boost/range/result_iterator.hpp> |
---|
| 23 | # include <boost/range/detail/common.hpp> |
---|
| 24 | # if BOOST_WORKAROUND(BOOST_MSVC, < 1310) |
---|
| 25 | # include <boost/range/detail/remove_extent.hpp> |
---|
| 26 | # endif |
---|
| 27 | |
---|
| 28 | namespace boost |
---|
| 29 | { |
---|
| 30 | namespace range_detail |
---|
| 31 | { |
---|
| 32 | template< typename T > |
---|
| 33 | struct range_end; |
---|
| 34 | |
---|
| 35 | ////////////////////////////////////////////////////////////////////// |
---|
| 36 | // default |
---|
| 37 | ////////////////////////////////////////////////////////////////////// |
---|
| 38 | |
---|
| 39 | template<> |
---|
| 40 | struct range_end<std_container_> |
---|
| 41 | { |
---|
| 42 | template< typename C > |
---|
| 43 | static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type |
---|
| 44 | fun( C& c ) |
---|
| 45 | { |
---|
| 46 | return c.end(); |
---|
| 47 | }; |
---|
| 48 | }; |
---|
| 49 | |
---|
| 50 | ////////////////////////////////////////////////////////////////////// |
---|
| 51 | // pair |
---|
| 52 | ////////////////////////////////////////////////////////////////////// |
---|
| 53 | |
---|
| 54 | template<> |
---|
| 55 | struct range_end<std_pair_> |
---|
| 56 | { |
---|
| 57 | template< typename P > |
---|
| 58 | static BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type |
---|
| 59 | fun( const P& p ) |
---|
| 60 | { |
---|
| 61 | return p.second; |
---|
| 62 | } |
---|
| 63 | }; |
---|
| 64 | |
---|
| 65 | ////////////////////////////////////////////////////////////////////// |
---|
| 66 | // array |
---|
| 67 | ////////////////////////////////////////////////////////////////////// |
---|
| 68 | |
---|
| 69 | template<> |
---|
| 70 | struct range_end<array_> |
---|
| 71 | { |
---|
| 72 | #if !BOOST_WORKAROUND(BOOST_MSVC, < 1310) |
---|
| 73 | template< typename T, std::size_t sz > |
---|
| 74 | static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) |
---|
| 75 | { |
---|
| 76 | return boost::range_detail::array_end( boost_range_array ); |
---|
| 77 | } |
---|
| 78 | #else |
---|
| 79 | template<typename T> |
---|
| 80 | static BOOST_RANGE_DEDUCED_TYPENAME remove_extent<T>::type* fun(T& t) |
---|
| 81 | { |
---|
| 82 | return t + remove_extent<T>::size; |
---|
| 83 | } |
---|
| 84 | #endif |
---|
| 85 | }; |
---|
| 86 | |
---|
| 87 | |
---|
| 88 | template<> |
---|
| 89 | struct range_end<char_array_> |
---|
| 90 | { |
---|
| 91 | template< typename T, std::size_t sz > |
---|
| 92 | static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) |
---|
| 93 | { |
---|
| 94 | return boost::range_detail::array_end( boost_range_array ); |
---|
| 95 | } |
---|
| 96 | }; |
---|
| 97 | |
---|
| 98 | template<> |
---|
| 99 | struct range_end<wchar_t_array_> |
---|
| 100 | { |
---|
| 101 | template< typename T, std::size_t sz > |
---|
| 102 | static T* fun( T BOOST_RANGE_ARRAY_REF()[sz] ) |
---|
| 103 | { |
---|
| 104 | return boost::range_detail::array_end( boost_range_array ); |
---|
| 105 | } |
---|
| 106 | }; |
---|
| 107 | |
---|
| 108 | ////////////////////////////////////////////////////////////////////// |
---|
| 109 | // string |
---|
| 110 | ////////////////////////////////////////////////////////////////////// |
---|
| 111 | |
---|
| 112 | template<> |
---|
| 113 | struct range_end<char_ptr_> |
---|
| 114 | { |
---|
| 115 | static char* fun( char* s ) |
---|
| 116 | { |
---|
| 117 | return boost::range_detail::str_end( s ); |
---|
| 118 | } |
---|
| 119 | }; |
---|
| 120 | |
---|
| 121 | template<> |
---|
| 122 | struct range_end<const_char_ptr_> |
---|
| 123 | { |
---|
| 124 | static const char* fun( const char* s ) |
---|
| 125 | { |
---|
| 126 | return boost::range_detail::str_end( s ); |
---|
| 127 | } |
---|
| 128 | }; |
---|
| 129 | |
---|
| 130 | template<> |
---|
| 131 | struct range_end<wchar_t_ptr_> |
---|
| 132 | { |
---|
| 133 | static wchar_t* fun( wchar_t* s ) |
---|
| 134 | { |
---|
| 135 | return boost::range_detail::str_end( s ); |
---|
| 136 | } |
---|
| 137 | }; |
---|
| 138 | |
---|
| 139 | |
---|
| 140 | template<> |
---|
| 141 | struct range_end<const_wchar_t_ptr_> |
---|
| 142 | { |
---|
| 143 | static const wchar_t* fun( const wchar_t* s ) |
---|
| 144 | { |
---|
| 145 | return boost::range_detail::str_end( s ); |
---|
| 146 | } |
---|
| 147 | }; |
---|
| 148 | |
---|
| 149 | } // namespace 'range_detail' |
---|
| 150 | |
---|
| 151 | template< typename C > |
---|
| 152 | inline BOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type |
---|
| 153 | end( C& c ) |
---|
| 154 | { |
---|
| 155 | return range_detail::range_end< BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type >::fun( c ); |
---|
| 156 | } |
---|
| 157 | |
---|
| 158 | } // namespace 'boost' |
---|
| 159 | |
---|
| 160 | # endif // VC6 |
---|
| 161 | #endif |
---|