| 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 | |
| 12 | //! \file |
| 13 | |
| 14 | #ifndef BOOST_MOVE_DETAIL_ITERATOR_TRAITS_HPP |
| 15 | #define BOOST_MOVE_DETAIL_ITERATOR_TRAITS_HPP |
| 16 | |
| 17 | #ifndef BOOST_CONFIG_HPP |
| 18 | # include <boost/config.hpp> |
| 19 | #endif |
| 20 | # |
| 21 | #if defined(BOOST_HAS_PRAGMA_ONCE) |
| 22 | # pragma once |
| 23 | #endif |
| 24 | |
| 25 | #if (BOOST_CXX_VERSION > 201703L) && defined(__cpp_lib_concepts) |
| 26 | |
| 27 | #include <iterator> |
| 28 | |
| 29 | #define BOOST_MOVE_CONTIGUOUS_ITERATOR_TAG |
| 30 | |
| 31 | namespace boost { |
| 32 | namespace movelib { |
| 33 | |
| 34 | using std::iterator_traits; |
| 35 | |
| 36 | template<class T> |
| 37 | struct iter_difference |
| 38 | { |
| 39 | typedef typename std::iterator_traits<T>::difference_type type; |
| 40 | }; |
| 41 | |
| 42 | template<class T> |
| 43 | struct iter_value |
| 44 | { |
| 45 | typedef typename std::iterator_traits<T>::value_type type; |
| 46 | }; |
| 47 | |
| 48 | template<class T> |
| 49 | struct iter_category |
| 50 | { |
| 51 | typedef typename std::iterator_traits<T>::iterator_category type; |
| 52 | }; |
| 53 | |
| 54 | }} //namespace boost::movelib |
| 55 | |
| 56 | #else |
| 57 | |
| 58 | #include <cstddef> |
| 59 | #include <boost/move/detail/type_traits.hpp> |
| 60 | |
| 61 | #include <boost/move/detail/std_ns_begin.hpp> |
| 62 | |
| 63 | BOOST_MOVE_STD_NS_BEG |
| 64 | |
| 65 | struct input_iterator_tag; |
| 66 | struct forward_iterator_tag; |
| 67 | struct bidirectional_iterator_tag; |
| 68 | struct random_access_iterator_tag; |
| 69 | struct output_iterator_tag; |
| 70 | |
| 71 | #if ( (defined(BOOST_GNU_STDLIB) && (__cplusplus > 201703L))\ |
| 72 | || (defined(_LIBCPP_VERSION) && (_LIBCPP_STD_VER > 17))\ |
| 73 | || (defined(_YVALS) && defined(_CPPLIB_VER) && defined(__cpp_lib_concepts))\ |
| 74 | || (__cplusplus >= 202002L)\ |
| 75 | ) |
| 76 | # define BOOST_MOVE_CONTIGUOUS_ITERATOR_TAG |
| 77 | struct contiguous_iterator_tag; |
| 78 | |
| 79 | #endif |
| 80 | |
| 81 | BOOST_MOVE_STD_NS_END |
| 82 | |
| 83 | #include <boost/move/detail/std_ns_end.hpp> |
| 84 | |
| 85 | namespace boost{ namespace movelib{ |
| 86 | |
| 87 | template<class T> |
| 88 | struct iter_difference |
| 89 | { |
| 90 | typedef typename T::difference_type type; |
| 91 | }; |
| 92 | |
| 93 | template<class T> |
| 94 | struct iter_difference<T*> |
| 95 | { |
| 96 | typedef std::ptrdiff_t type; |
| 97 | }; |
| 98 | |
| 99 | template<class T> |
| 100 | struct iter_value |
| 101 | { |
| 102 | typedef typename T::value_type type; |
| 103 | }; |
| 104 | |
| 105 | template<class T> |
| 106 | struct iter_value<T*> |
| 107 | { |
| 108 | typedef T type; |
| 109 | }; |
| 110 | |
| 111 | template<class T> |
| 112 | struct iter_value<const T*> |
| 113 | { |
| 114 | typedef T type; |
| 115 | }; |
| 116 | |
| 117 | template<class T> |
| 118 | struct iter_category |
| 119 | { |
| 120 | typedef typename T::iterator_category type; |
| 121 | }; |
| 122 | |
| 123 | |
| 124 | template<class T> |
| 125 | struct iter_category<T*> |
| 126 | { |
| 127 | typedef std::random_access_iterator_tag type; |
| 128 | }; |
| 129 | |
| 130 | template<class Iterator> |
| 131 | struct iterator_traits |
| 132 | { |
| 133 | typedef typename iter_difference<Iterator>::type difference_type; |
| 134 | typedef typename iter_value<Iterator>::type value_type; |
| 135 | typedef typename Iterator::pointer pointer; |
| 136 | typedef typename Iterator::reference reference; |
| 137 | typedef typename iter_category<Iterator>::type iterator_category; |
| 138 | }; |
| 139 | |
| 140 | template<class T> |
| 141 | struct iterator_traits<T*> |
| 142 | { |
| 143 | typedef std::ptrdiff_t difference_type; |
| 144 | typedef T value_type; |
| 145 | typedef T* pointer; |
| 146 | typedef T& reference; |
| 147 | typedef std::random_access_iterator_tag iterator_category; |
| 148 | }; |
| 149 | |
| 150 | template<class T> |
| 151 | struct iterator_traits<const T*> |
| 152 | { |
| 153 | typedef std::ptrdiff_t difference_type; |
| 154 | typedef T value_type; |
| 155 | typedef const T* pointer; |
| 156 | typedef const T& reference; |
| 157 | typedef std::random_access_iterator_tag iterator_category; |
| 158 | }; |
| 159 | |
| 160 | }} //namespace boost::movelib |
| 161 | |
| 162 | #endif // |
| 163 | |
| 164 | #include <boost/move/detail/type_traits.hpp> |
| 165 | |
| 166 | namespace boost { |
| 167 | namespace movelib { |
| 168 | |
| 169 | template<class T> |
| 170 | struct iter_size |
| 171 | : boost::move_detail:: |
| 172 | make_unsigned<typename iter_difference<T>::type > |
| 173 | {}; |
| 174 | |
| 175 | }} //namespace boost move_detail { |
| 176 | |
| 177 | #endif //#ifndef BOOST_MOVE_DETAIL_ITERATOR_TRAITS_HPP |
| 178 | |