summaryrefslogtreecommitdiff
path: root/src/jit/jitstd/iterator.h
blob: 975755c59cad58e7447ec2be21630bb66706b912 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.



#pragma once

namespace jitstd
{

template <class Category, class T, class Distance = ptrdiff_t, class Pointer = T*, class Reference = T&>
struct iterator
{
    typedef T value_type;
    typedef Distance difference_type;
    typedef Pointer pointer;
    typedef Reference reference;
    typedef Category iterator_category;
};

struct input_iterator_tag
{
};

struct forward_iterator_tag : public input_iterator_tag
{
};

struct bidirectional_iterator_tag : public forward_iterator_tag
{
};

struct random_access_iterator_tag : public bidirectional_iterator_tag
{
};

struct int_not_an_iterator_tag
{
};

template <typename Iterator>
struct iterator_traits
{
    typedef typename Iterator::difference_type difference_type;
    typedef typename Iterator::value_type value_type;
    typedef typename Iterator::pointer pointer;
    typedef typename Iterator::reference reference;
    typedef typename Iterator::iterator_category iterator_category;
};

template <typename T>
struct iterator_traits<T*>
{
    typedef ptrdiff_t difference_type;
    typedef T value_type;
    typedef T* pointer;
    typedef T& reference;
    typedef random_access_iterator_tag iterator_category;
};

template <typename T>
struct iterator_traits<const T*>
{
    typedef ptrdiff_t difference_type;
    typedef T value_type;
    typedef const T* pointer;
    typedef const T& reference;
    typedef random_access_iterator_tag iterator_category;
};

template<>
struct iterator_traits<bool>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<char>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<signed char>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<unsigned char>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<short>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<unsigned short>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<int>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<unsigned int>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<__int64>
{
    typedef int_not_an_iterator_tag iterator_category;
};

template<>
struct iterator_traits<unsigned __int64>
{
    typedef int_not_an_iterator_tag iterator_category;
};

namespace util
{
template<class Iterator>
inline
typename iterator_traits<Iterator>::iterator_category
    iterator_category(const Iterator&)
{
    typename iterator_traits<Iterator>::iterator_category categ;
    return categ;
}
} // end of namespace util.

} // end of namespace jitstd.