@@ -65,78 +65,84 @@ constexpr void test_iterators() {
65
65
using ValueT = std::iter_value_t <Iter>;
66
66
{ // simple tests
67
67
ValueT a[] = {1 , 2 , 3 , 4 , 5 , 6 };
68
- auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 6 )));
69
68
{
69
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 6 )));
70
70
std::same_as<bool > decltype (auto ) ret = std::ranges::contains (whole.begin (), whole.end (), 3 );
71
71
assert (ret);
72
72
}
73
73
{
74
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 6 )));
74
75
std::same_as<bool > decltype (auto ) ret = std::ranges::contains (whole, 3 );
75
76
assert (ret);
76
77
}
77
78
}
78
79
79
80
{ // check that a range with a single element works
80
81
ValueT a[] = {32 };
81
- auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 1 )));
82
82
{
83
- bool ret = std::ranges::contains (whole.begin (), whole.end (), 32 );
83
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 1 )));
84
+ bool ret = std::ranges::contains (whole.begin (), whole.end (), 32 );
84
85
assert (ret);
85
86
}
86
87
{
87
- bool ret = std::ranges::contains (whole, 32 );
88
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 1 )));
89
+ bool ret = std::ranges::contains (whole, 32 );
88
90
assert (ret);
89
91
}
90
92
}
91
93
92
94
{ // check that an empty range works
93
95
std::array<ValueT, 0 > a = {};
94
- auto whole = std::ranges::subrange (Iter (a.data ()), Sent (Iter (a.data ())));
95
96
{
96
- bool ret = std::ranges::contains (whole.begin (), whole.end (), 1 );
97
+ auto whole = std::ranges::subrange (Iter (a.data ()), Sent (Iter (a.data ())));
98
+ bool ret = std::ranges::contains (whole.begin (), whole.end (), 1 );
97
99
assert (!ret);
98
100
}
99
101
{
100
- bool ret = std::ranges::contains (whole, 1 );
102
+ auto whole = std::ranges::subrange (Iter (a.data ()), Sent (Iter (a.data ())));
103
+ bool ret = std::ranges::contains (whole, 1 );
101
104
assert (!ret);
102
105
}
103
106
}
104
107
105
108
{ // check that the first element matches
106
109
ValueT a[] = {32 , 3 , 2 , 1 , 0 , 23 , 21 , 9 , 40 , 100 };
107
- auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 10 )));
108
110
{
109
- bool ret = std::ranges::contains (whole.begin (), whole.end (), 32 );
111
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 10 )));
112
+ bool ret = std::ranges::contains (whole.begin (), whole.end (), 32 );
110
113
assert (ret);
111
114
}
112
115
{
113
- bool ret = std::ranges::contains (whole, 32 );
116
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 10 )));
117
+ bool ret = std::ranges::contains (whole, 32 );
114
118
assert (ret);
115
119
}
116
120
}
117
121
118
122
{ // check that the last element matches
119
123
ValueT a[] = {3 , 22 , 1 , 43 , 99 , 0 , 56 , 100 , 32 };
120
- auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 9 )));
121
124
{
122
- bool ret = std::ranges::contains (whole.begin (), whole.end (), 32 );
125
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 9 )));
126
+ bool ret = std::ranges::contains (whole.begin (), whole.end (), 32 );
123
127
assert (ret);
124
128
}
125
129
{
126
- bool ret = std::ranges::contains (whole, 32 );
130
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 9 )));
131
+ bool ret = std::ranges::contains (whole, 32 );
127
132
assert (ret);
128
133
}
129
134
}
130
135
131
136
{ // no match
132
137
ValueT a[] = {13 , 1 , 21 , 4 , 5 };
133
- auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 5 )));
134
138
{
135
- bool ret = std::ranges::contains (whole.begin (), whole.end (), 10 );
139
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 5 )));
140
+ bool ret = std::ranges::contains (whole.begin (), whole.end (), 10 );
136
141
assert (!ret);
137
142
}
138
143
{
139
- bool ret = std::ranges::contains (whole, 10 );
144
+ auto whole = std::ranges::subrange (Iter (a), Sent (Iter (a + 5 )));
145
+ bool ret = std::ranges::contains (whole, 10 );
140
146
assert (!ret);
141
147
}
142
148
}
0 commit comments