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
31namespace boost {
32namespace 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
63BOOST_MOVE_STD_NS_BEG
64
65struct input_iterator_tag;
66struct forward_iterator_tag;
67struct bidirectional_iterator_tag;
68struct random_access_iterator_tag;
69struct 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
77struct contiguous_iterator_tag;
78
79#endif
80
81BOOST_MOVE_STD_NS_END
82
83#include <boost/move/detail/std_ns_end.hpp>
84
85namespace boost{ namespace movelib{
86
87template<class T>
88struct iter_difference
89{
90 typedef typename T::difference_type type;
91};
92
93template<class T>
94struct iter_difference<T*>
95{
96 typedef std::ptrdiff_t type;
97};
98
99template<class T>
100struct iter_value
101{
102 typedef typename T::value_type type;
103};
104
105template<class T>
106struct iter_value<T*>
107{
108 typedef T type;
109};
110
111template<class T>
112struct iter_value<const T*>
113{
114 typedef T type;
115};
116
117template<class T>
118struct iter_category
119{
120 typedef typename T::iterator_category type;
121};
122
123
124template<class T>
125struct iter_category<T*>
126{
127 typedef std::random_access_iterator_tag type;
128};
129
130template<class Iterator>
131struct 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
140template<class T>
141struct 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
150template<class T>
151struct 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
166namespace boost {
167namespace movelib {
168
169template<class T>
170struct 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