iterator_traits.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. # include <boost/detail/iterator.hpp>
  8. # include <boost/detail/workaround.hpp>
  9. namespace boost {
  10. // Unfortunately, g++ 2.95.x chokes when we define a class template
  11. // iterator_category which has the same name as its
  12. // std::iterator_category() function, probably due in part to the
  13. // "std:: is visible globally" hack it uses. Use
  14. // BOOST_ITERATOR_CATEGORY to write code that's portable to older
  15. // GCCs.
  16. # if BOOST_WORKAROUND(__GNUC__, <= 2)
  17. # define BOOST_ITERATOR_CATEGORY iterator_category_
  18. # else
  19. # define BOOST_ITERATOR_CATEGORY iterator_category
  20. # endif
  21. template <class Iterator>
  22. struct iterator_value
  23. {
  24. typedef typename boost::detail::iterator_traits<Iterator>::value_type type;
  25. };
  26. template <class Iterator>
  27. struct iterator_reference
  28. {
  29. typedef typename boost::detail::iterator_traits<Iterator>::reference type;
  30. };
  31. template <class Iterator>
  32. struct iterator_pointer
  33. {
  34. typedef typename boost::detail::iterator_traits<Iterator>::pointer type;
  35. };
  36. template <class Iterator>
  37. struct iterator_difference
  38. {
  39. typedef typename boost::detail::iterator_traits<Iterator>::difference_type type;
  40. };
  41. template <class Iterator>
  42. struct BOOST_ITERATOR_CATEGORY
  43. {
  44. typedef typename boost::detail::iterator_traits<Iterator>::iterator_category type;
  45. };
  46. # if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
  47. template <>
  48. struct iterator_value<int>
  49. {
  50. typedef void type;
  51. };
  52. template <>
  53. struct iterator_reference<int>
  54. {
  55. typedef void type;
  56. };
  57. template <>
  58. struct iterator_pointer<int>
  59. {
  60. typedef void type;
  61. };
  62. template <>
  63. struct iterator_difference<int>
  64. {
  65. typedef void type;
  66. };
  67. template <>
  68. struct BOOST_ITERATOR_CATEGORY<int>
  69. {
  70. typedef void type;
  71. };
  72. # endif
  73. } // namespace boost::iterator
  74. #endif // ITERATOR_TRAITS_DWA200347_HPP