| 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_ITERATOR_HPP |
|---|
| 12 | #define BOOST_RANGE_DETAIL_ITERATOR_HPP |
|---|
| 13 | |
|---|
| 14 | #include <boost/range/detail/common.hpp> |
|---|
| 15 | #include <boost/range/detail/remove_extent.hpp> |
|---|
| 16 | |
|---|
| 17 | #include <boost/static_assert.hpp> |
|---|
| 18 | |
|---|
| 19 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 20 | // missing partial specialization workaround. |
|---|
| 21 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 22 | |
|---|
| 23 | namespace boost |
|---|
| 24 | { |
|---|
| 25 | namespace range_detail |
|---|
| 26 | { |
|---|
| 27 | template< typename T > |
|---|
| 28 | struct range_iterator_ { |
|---|
| 29 | template< typename C > |
|---|
| 30 | struct pts |
|---|
| 31 | { |
|---|
| 32 | typedef int type; |
|---|
| 33 | }; |
|---|
| 34 | }; |
|---|
| 35 | |
|---|
| 36 | template<> |
|---|
| 37 | struct range_iterator_<std_container_> |
|---|
| 38 | { |
|---|
| 39 | template< typename C > |
|---|
| 40 | struct pts |
|---|
| 41 | { |
|---|
| 42 | typedef BOOST_RANGE_DEDUCED_TYPENAME C::iterator type; |
|---|
| 43 | }; |
|---|
| 44 | }; |
|---|
| 45 | |
|---|
| 46 | template<> |
|---|
| 47 | struct range_iterator_<std_pair_> |
|---|
| 48 | { |
|---|
| 49 | template< typename P > |
|---|
| 50 | struct pts |
|---|
| 51 | { |
|---|
| 52 | typedef BOOST_RANGE_DEDUCED_TYPENAME P::first_type type; |
|---|
| 53 | }; |
|---|
| 54 | }; |
|---|
| 55 | |
|---|
| 56 | template<> |
|---|
| 57 | struct range_iterator_<array_> |
|---|
| 58 | { |
|---|
| 59 | template< typename T > |
|---|
| 60 | struct pts |
|---|
| 61 | { |
|---|
| 62 | typedef BOOST_RANGE_DEDUCED_TYPENAME |
|---|
| 63 | remove_extent<T>::type* type; |
|---|
| 64 | }; |
|---|
| 65 | }; |
|---|
| 66 | |
|---|
| 67 | template<> |
|---|
| 68 | struct range_iterator_<char_array_> |
|---|
| 69 | { |
|---|
| 70 | template< typename T > |
|---|
| 71 | struct pts |
|---|
| 72 | { |
|---|
| 73 | typedef BOOST_RANGE_DEDUCED_TYPENAME |
|---|
| 74 | remove_extent<T>::type* type; |
|---|
| 75 | }; |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | template<> |
|---|
| 79 | struct range_iterator_<char_ptr_> |
|---|
| 80 | { |
|---|
| 81 | template< typename S > |
|---|
| 82 | struct pts |
|---|
| 83 | { |
|---|
| 84 | typedef char* type; |
|---|
| 85 | }; |
|---|
| 86 | }; |
|---|
| 87 | |
|---|
| 88 | template<> |
|---|
| 89 | struct range_iterator_<const_char_ptr_> |
|---|
| 90 | { |
|---|
| 91 | template< typename S > |
|---|
| 92 | struct pts |
|---|
| 93 | { |
|---|
| 94 | typedef const char* type; |
|---|
| 95 | }; |
|---|
| 96 | }; |
|---|
| 97 | |
|---|
| 98 | template<> |
|---|
| 99 | struct range_iterator_<wchar_t_ptr_> |
|---|
| 100 | { |
|---|
| 101 | template< typename S > |
|---|
| 102 | struct pts |
|---|
| 103 | { |
|---|
| 104 | typedef wchar_t* type; |
|---|
| 105 | }; |
|---|
| 106 | }; |
|---|
| 107 | |
|---|
| 108 | template<> |
|---|
| 109 | struct range_iterator_<const_wchar_t_ptr_> |
|---|
| 110 | { |
|---|
| 111 | template< typename S > |
|---|
| 112 | struct pts |
|---|
| 113 | { |
|---|
| 114 | typedef const wchar_t* type; |
|---|
| 115 | }; |
|---|
| 116 | }; |
|---|
| 117 | } |
|---|
| 118 | |
|---|
| 119 | template< typename C > |
|---|
| 120 | class range_iterator |
|---|
| 121 | { |
|---|
| 122 | typedef BOOST_RANGE_DEDUCED_TYPENAME range_detail::range<C>::type c_type; |
|---|
| 123 | public: |
|---|
| 124 | typedef typename range_detail::range_iterator_<c_type>::BOOST_NESTED_TEMPLATE pts<C>::type type; |
|---|
| 125 | }; |
|---|
| 126 | } |
|---|
| 127 | |
|---|
| 128 | #endif |
|---|