Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // Copyright David Abrahams 2003. |
| 2 | // Distributed under the Boost Software License, Version 1.0. (See |
| 3 | // accompanying file LICENSE_1_0.txt or copy at |
| 4 | // http://www.boost.org/LICENSE_1_0.txt) |
| 5 | #ifndef ITERATOR_TRAITS_DWA200347_HPP |
| 6 | # define ITERATOR_TRAITS_DWA200347_HPP |
| 7 | |
| 8 | # include <ndnboost/detail/iterator.hpp> |
| 9 | # include <ndnboost/detail/workaround.hpp> |
| 10 | |
| 11 | namespace ndnboost { |
| 12 | |
| 13 | // Unfortunately, g++ 2.95.x chokes when we define a class template |
| 14 | // iterator_category which has the same name as its |
| 15 | // std::iterator_category() function, probably due in part to the |
| 16 | // "std:: is visible globally" hack it uses. Use |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 17 | // NDNBOOST_ITERATOR_CATEGORY to write code that's portable to older |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 18 | // GCCs. |
| 19 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 20 | # if NDNBOOST_WORKAROUND(__GNUC__, <= 2) |
| 21 | # define NDNBOOST_ITERATOR_CATEGORY iterator_category_ |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 22 | # else |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 23 | # define NDNBOOST_ITERATOR_CATEGORY iterator_category |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 24 | # endif |
| 25 | |
| 26 | |
| 27 | template <class Iterator> |
| 28 | struct iterator_value |
| 29 | { |
| 30 | typedef typename ndnboost::detail::iterator_traits<Iterator>::value_type type; |
| 31 | }; |
| 32 | |
| 33 | template <class Iterator> |
| 34 | struct iterator_reference |
| 35 | { |
| 36 | typedef typename ndnboost::detail::iterator_traits<Iterator>::reference type; |
| 37 | }; |
| 38 | |
| 39 | |
| 40 | template <class Iterator> |
| 41 | struct iterator_pointer |
| 42 | { |
| 43 | typedef typename ndnboost::detail::iterator_traits<Iterator>::pointer type; |
| 44 | }; |
| 45 | |
| 46 | template <class Iterator> |
| 47 | struct iterator_difference |
| 48 | { |
| 49 | typedef typename ndnboost::detail::iterator_traits<Iterator>::difference_type type; |
| 50 | }; |
| 51 | |
| 52 | template <class Iterator> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 53 | struct NDNBOOST_ITERATOR_CATEGORY |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 54 | { |
| 55 | typedef typename ndnboost::detail::iterator_traits<Iterator>::iterator_category type; |
| 56 | }; |
| 57 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 58 | # if NDNBOOST_WORKAROUND(NDNBOOST_MSVC, < 1300) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 59 | template <> |
| 60 | struct iterator_value<int> |
| 61 | { |
| 62 | typedef void type; |
| 63 | }; |
| 64 | |
| 65 | template <> |
| 66 | struct iterator_reference<int> |
| 67 | { |
| 68 | typedef void type; |
| 69 | }; |
| 70 | |
| 71 | template <> |
| 72 | struct iterator_pointer<int> |
| 73 | { |
| 74 | typedef void type; |
| 75 | }; |
| 76 | |
| 77 | template <> |
| 78 | struct iterator_difference<int> |
| 79 | { |
| 80 | typedef void type; |
| 81 | }; |
| 82 | |
| 83 | template <> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 84 | struct NDNBOOST_ITERATOR_CATEGORY<int> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 85 | { |
| 86 | typedef void type; |
| 87 | }; |
| 88 | # endif |
| 89 | |
| 90 | } // namespace ndnboost::iterator |
| 91 | |
| 92 | #endif // ITERATOR_TRAITS_DWA200347_HPP |