Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // iterator.hpp workarounds for non-conforming standard libraries ---------// |
| 2 | |
| 3 | // (C) Copyright Beman Dawes 2000. Distributed under the Boost |
| 4 | // Software License, Version 1.0. (See accompanying file |
| 5 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | |
| 7 | // See http://www.boost.org/libs/utility for documentation. |
| 8 | |
| 9 | // Revision History |
| 10 | // 12 Jan 01 added <cstddef> for std::ptrdiff_t (Jens Maurer) |
| 11 | // 28 Jun 00 Workarounds to deal with known MSVC bugs (David Abrahams) |
| 12 | // 26 Jun 00 Initial version (Jeremy Siek) |
| 13 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 14 | #ifndef NDNBOOST_ITERATOR_HPP |
| 15 | #define NDNBOOST_ITERATOR_HPP |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 16 | |
| 17 | #include <iterator> |
| 18 | #include <cstddef> // std::ptrdiff_t |
| 19 | #include <ndnboost/config.hpp> |
| 20 | |
| 21 | namespace ndnboost |
| 22 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 23 | # if defined(NDNBOOST_NO_STD_ITERATOR) && !defined(NDNBOOST_MSVC_STD_ITERATOR) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 24 | template <class Category, class T, |
| 25 | class Distance = std::ptrdiff_t, |
| 26 | class Pointer = T*, class Reference = T&> |
| 27 | struct iterator |
| 28 | { |
| 29 | typedef T value_type; |
| 30 | typedef Distance difference_type; |
| 31 | typedef Pointer pointer; |
| 32 | typedef Reference reference; |
| 33 | typedef Category iterator_category; |
| 34 | }; |
| 35 | # else |
| 36 | |
| 37 | // declare iterator_base in namespace detail to work around MSVC bugs which |
| 38 | // prevent derivation from an identically-named class in a different namespace. |
| 39 | namespace detail { |
| 40 | template <class Category, class T, class Distance, class Pointer, class Reference> |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 41 | # if !defined(NDNBOOST_MSVC_STD_ITERATOR) |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 42 | struct iterator_base : std::iterator<Category, T, Distance, Pointer, Reference> {}; |
| 43 | # else |
| 44 | struct iterator_base : std::iterator<Category, T, Distance> |
| 45 | { |
| 46 | typedef Reference reference; |
| 47 | typedef Pointer pointer; |
| 48 | typedef Distance difference_type; |
| 49 | }; |
| 50 | # endif |
| 51 | } |
| 52 | |
| 53 | template <class Category, class T, class Distance = std::ptrdiff_t, |
| 54 | class Pointer = T*, class Reference = T&> |
| 55 | struct iterator : ndnboost::detail::iterator_base<Category, T, Distance, Pointer, Reference> {}; |
| 56 | # endif |
| 57 | } // namespace ndnboost |
| 58 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame] | 59 | #endif // NDNBOOST_ITERATOR_HPP |