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