iterator_traits.hpp 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2014-2014.
  4. // Distributed under the Boost Software License, Version 1.0.
  5. // (See accompanying file LICENSE_1_0.txt or copy at
  6. // http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See http://www.boost.org/libs/move for documentation.
  9. //
  10. //////////////////////////////////////////////////////////////////////////////
  11. //! \file
  12. #ifndef BOOST_MOVE_DETAIL_ITERATOR_TRAITS_HPP
  13. #define BOOST_MOVE_DETAIL_ITERATOR_TRAITS_HPP
  14. #ifndef BOOST_CONFIG_HPP
  15. # include <boost/config.hpp>
  16. #endif
  17. #
  18. #if defined(BOOST_HAS_PRAGMA_ONCE)
  19. # pragma once
  20. #endif
  21. #include <cstddef>
  22. #include <boost/move/detail/type_traits.hpp>
  23. #include <boost/move/detail/std_ns_begin.hpp>
  24. BOOST_MOVE_STD_NS_BEG
  25. struct input_iterator_tag;
  26. struct forward_iterator_tag;
  27. struct bidirectional_iterator_tag;
  28. struct random_access_iterator_tag;
  29. struct output_iterator_tag;
  30. BOOST_MOVE_STD_NS_END
  31. #include <boost/move/detail/std_ns_end.hpp>
  32. namespace boost{ namespace movelib{
  33. template<class Iterator>
  34. struct iterator_traits
  35. {
  36. typedef typename Iterator::difference_type difference_type;
  37. typedef typename Iterator::value_type value_type;
  38. typedef typename Iterator::pointer pointer;
  39. typedef typename Iterator::reference reference;
  40. typedef typename Iterator::iterator_category iterator_category;
  41. typedef typename boost::move_detail::make_unsigned<difference_type>::type size_type;
  42. };
  43. template<class T>
  44. struct iterator_traits<T*>
  45. {
  46. typedef std::ptrdiff_t difference_type;
  47. typedef T value_type;
  48. typedef T* pointer;
  49. typedef T& reference;
  50. typedef std::random_access_iterator_tag iterator_category;
  51. typedef typename boost::move_detail::make_unsigned<difference_type>::type size_type;
  52. };
  53. template<class T>
  54. struct iterator_traits<const T*>
  55. {
  56. typedef std::ptrdiff_t difference_type;
  57. typedef T value_type;
  58. typedef const T* pointer;
  59. typedef const T& reference;
  60. typedef std::random_access_iterator_tag iterator_category;
  61. typedef typename boost::move_detail::make_unsigned<difference_type>::type size_type;
  62. };
  63. }} //namespace boost { namespace movelib{
  64. #endif //#ifndef BOOST_MOVE_DETAIL_ITERATOR_TRAITS_HPP