Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 11 | #ifndef NDNBOOST_RANGE_DETAIL_VC6_END_HPP |
| 12 | #define NDNBOOST_RANGE_DETAIL_VC6_END_HPP |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 13 | |
| 14 | #include <ndnboost/range/detail/implementation_help.hpp> |
| 15 | #include <ndnboost/range/detail/implementation_help.hpp> |
| 16 | #include <ndnboost/range/result_iterator.hpp> |
| 17 | #include <ndnboost/range/detail/common.hpp> |
| 18 | #include <ndnboost/range/detail/remove_extent.hpp> |
| 19 | |
| 20 | namespace ndnboost |
| 21 | { |
| 22 | namespace range_detail |
| 23 | { |
| 24 | template< typename T > |
| 25 | struct range_end; |
| 26 | |
| 27 | ////////////////////////////////////////////////////////////////////// |
| 28 | // default |
| 29 | ////////////////////////////////////////////////////////////////////// |
| 30 | |
| 31 | template<> |
| 32 | struct range_end<std_container_> |
| 33 | { |
| 34 | template< typename C > |
| 35 | struct inner { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 36 | static NDNBOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<C>::type |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 37 | fun( C& c ) |
| 38 | { |
| 39 | return c.end(); |
| 40 | }; |
| 41 | }; |
| 42 | }; |
| 43 | |
| 44 | ////////////////////////////////////////////////////////////////////// |
| 45 | // pair |
| 46 | ////////////////////////////////////////////////////////////////////// |
| 47 | |
| 48 | template<> |
| 49 | struct range_end<std_pair_> |
| 50 | { |
| 51 | template< typename P > |
| 52 | struct inner { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 53 | static NDNBOOST_RANGE_DEDUCED_TYPENAME range_result_iterator<P>::type |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 54 | fun( const P& p ) |
| 55 | { |
| 56 | return p.second; |
| 57 | } |
| 58 | }; |
| 59 | }; |
| 60 | |
| 61 | ////////////////////////////////////////////////////////////////////// |
| 62 | // array |
| 63 | ////////////////////////////////////////////////////////////////////// |
| 64 | |
| 65 | template<> |
| 66 | struct range_end<array_> |
| 67 | { |
| 68 | template< typename T > |
| 69 | struct inner { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 70 | static NDNBOOST_DEDUCED_TYPENAME remove_extent<T>::type* |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 71 | fun(T& t) |
| 72 | { |
| 73 | return t + remove_extent<T>::size; |
| 74 | } |
| 75 | }; |
| 76 | }; |
| 77 | |
| 78 | |
| 79 | template<> |
| 80 | struct range_end<char_array_> |
| 81 | { |
| 82 | template< typename T > |
| 83 | struct inner { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 84 | static NDNBOOST_DEDUCED_TYPENAME remove_extent<T>::type* |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 85 | fun(T& t) |
| 86 | { |
| 87 | return t + remove_extent<T>::size; |
| 88 | } |
| 89 | }; |
| 90 | }; |
| 91 | |
| 92 | template<> |
| 93 | struct range_end<wchar_t_array_> |
| 94 | { |
| 95 | template< typename T > |
| 96 | struct inner { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 97 | static NDNBOOST_DEDUCED_TYPENAME remove_extent<T>::type* |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 98 | fun(T& t) |
| 99 | { |
| 100 | return t + remove_extent<T>::size; |
| 101 | } |
| 102 | }; |
| 103 | }; |
| 104 | |
| 105 | ////////////////////////////////////////////////////////////////////// |
| 106 | // string |
| 107 | ////////////////////////////////////////////////////////////////////// |
| 108 | |
| 109 | template<> |
| 110 | struct range_end<char_ptr_> |
| 111 | { |
| 112 | template< typename T > |
| 113 | struct inner { |
| 114 | static char* fun( char* s ) |
| 115 | { |
| 116 | return ndnboost::range_detail::str_end( s ); |
| 117 | } |
| 118 | }; |
| 119 | }; |
| 120 | |
| 121 | template<> |
| 122 | struct range_end<const_char_ptr_> |
| 123 | { |
| 124 | template< typename T > |
| 125 | struct inner { |
| 126 | static const char* fun( const char* s ) |
| 127 | { |
| 128 | return ndnboost::range_detail::str_end( s ); |
| 129 | } |
| 130 | }; |
| 131 | }; |
| 132 | |
| 133 | template<> |
| 134 | struct range_end<wchar_t_ptr_> |
| 135 | { |
| 136 | template< typename T > |
| 137 | struct inner { |
| 138 | static wchar_t* fun( wchar_t* s ) |
| 139 | { |
| 140 | return ndnboost::range_detail::str_end( s ); |
| 141 | } |
| 142 | }; |
| 143 | }; |
| 144 | |
| 145 | |
| 146 | template<> |
| 147 | struct range_end<const_wchar_t_ptr_> |
| 148 | { |
| 149 | template< typename T > |
| 150 | struct inner { |
| 151 | static const wchar_t* fun( const wchar_t* s ) |
| 152 | { |
| 153 | return ndnboost::range_detail::str_end( s ); |
| 154 | } |
| 155 | }; |
| 156 | }; |
| 157 | |
| 158 | } // namespace 'range_detail' |
| 159 | |
| 160 | template< typename C > |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 161 | inline NDNBOOST_DEDUCED_TYPENAME range_result_iterator<C>::type |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 162 | end( C& c ) |
| 163 | { |
| 164 | return range_detail::range_end<range_detail::range<C>::type>::inner<C>::fun( c ); |
| 165 | } |
| 166 | |
| 167 | } // namespace 'boost' |
| 168 | |
| 169 | |
| 170 | #endif |