Skip to content

Commit 102e4a9

Browse files
random access iterator test
1 parent d4afc6a commit 102e4a9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
// REQUIRES: has-unix-headers, std-at-least-c++26
10+
11+
#include <ranges>
12+
#include <cassert>
13+
#include <vector>
14+
15+
constexpr bool test() {
16+
std::vector<int> v1 = {1, 2, 3};
17+
std::vector<int> v2 = {4, 5, 6};
18+
auto cv = std::views::concat(v1, v2);
19+
static_assert(std::random_access_iterator<decltype(cv.begin())>);
20+
assert(cv[0] == 1);
21+
assert(cv[2] == 3);
22+
assert(cv[3] == 4);
23+
assert(cv[5] == 6);
24+
return true;
25+
}
26+
27+
int main(int, char**) {
28+
test();
29+
static_assert(test());
30+
31+
return 0;
32+
}

0 commit comments

Comments
 (0)