iterator.hpp 1.9 KB

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