1// Licensed to the .NET Foundation under one or more agreements.
2// The .NET Foundation licenses this file to you under the MIT license.
3// See the LICENSE file in the project root for more information.
4
5
6
7#pragma once
8
9namespace jitstd
10{
11
12template <class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&>
13struct iterator
14{
15 typedef T value_type;
16 typedef Distance difference_type;
17 typedef Pointer pointer;
18 typedef Reference reference;
19 typedef Category iterator_category;
20};
21
22struct input_iterator_tag
23{
24};
25
26struct forward_iterator_tag : public input_iterator_tag
27{
28};
29
30struct bidirectional_iterator_tag : public forward_iterator_tag
31{
32};
33
34struct random_access_iterator_tag : public bidirectional_iterator_tag
35{
36};
37
38struct int_not_an_iterator_tag
39{
40};
41
42template <typename Iterator>
43struct iterator_traits
44{
45 typedef typename Iterator::difference_type difference_type;
46 typedef typename Iterator::value_type value_type;
47 typedef typename Iterator::pointer pointer;
48 typedef typename Iterator::reference reference;
49 typedef typename Iterator::iterator_category iterator_category;
50};
51
52template <typename T>
53struct iterator_traits<T*>
54{
55 typedef ptrdiff_t difference_type;
56 typedef T value_type;
57 typedef T* pointer;
58 typedef T& reference;
59 typedef random_access_iterator_tag iterator_category;
60};
61
62template <typename T>
63struct iterator_traits<const T*>
64{
65 typedef ptrdiff_t difference_type;
66 typedef T value_type;
67 typedef const T* pointer;
68 typedef const T& reference;
69 typedef random_access_iterator_tag iterator_category;
70};
71
72template<>
73struct iterator_traits<bool>
74{
75 typedef int_not_an_iterator_tag iterator_category;
76};
77
78template<>
79struct iterator_traits<char>
80{
81 typedef int_not_an_iterator_tag iterator_category;
82};
83
84template<>
85struct iterator_traits<signed char>
86{
87 typedef int_not_an_iterator_tag iterator_category;
88};
89
90template<>
91struct iterator_traits<unsigned char>
92{
93 typedef int_not_an_iterator_tag iterator_category;
94};
95
96template<>
97struct iterator_traits<short>
98{
99 typedef int_not_an_iterator_tag iterator_category;
100};
101
102template<>
103struct iterator_traits<unsigned short>
104{
105 typedef int_not_an_iterator_tag iterator_category;
106};
107
108template<>
109struct iterator_traits<int>
110{
111 typedef int_not_an_iterator_tag iterator_category;
112};
113
114template<>
115struct iterator_traits<unsigned int>
116{
117 typedef int_not_an_iterator_tag iterator_category;
118};
119
120template<>
121struct iterator_traits<__int64>
122{
123 typedef int_not_an_iterator_tag iterator_category;
124};
125
126template<>
127struct iterator_traits<unsigned __int64>
128{
129 typedef int_not_an_iterator_tag iterator_category;
130};
131
132namespace util
133{
134template<class Iterator>
135inline
136typename iterator_traits<Iterator>::iterator_category
137 iterator_category(const Iterator&)
138{
139 typename iterator_traits<Iterator>::iterator_category categ;
140 return categ;
141}
142} // end of namespace util.
143
144} // end of namespace jitstd.
145