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 // UNSUPPORTED: c++03, c++11, c++14, c++17
10 // UNSUPPORTED: libcpp-no-concepts
11 // UNSUPPORTED: gcc-10
12 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
13
14 // class std::ranges::subrange;
15
16 #include <ranges>
17
18 #include <cassert>
19 #include "test_macros.h"
20 #include "test_iterators.h"
21 #include "../subrange_test_types.h"
22
23 template<size_t I, class S>
24 concept GetInvocable = requires {
25 std::get<I>(std::declval<S>());
26 };
27
28 static_assert( GetInvocable<0, std::ranges::subrange<int*>>);
29 static_assert( GetInvocable<1, std::ranges::subrange<int*>>);
30 static_assert(!GetInvocable<2, std::ranges::subrange<int*>>);
31 static_assert(!GetInvocable<3, std::ranges::subrange<int*>>);
32
test()33 constexpr bool test() {
34 std::ranges::subrange<int*> a(globalBuff, globalBuff + 8, 8);
35 assert(std::get<0>(a) == a.begin());
36 assert(std::get<1>(a) == a.end());
37
38 assert(a.begin() == std::get<0>(std::move(a)));
39 std::ranges::subrange<int*> b(globalBuff, globalBuff + 8, 8);
40 assert(b.end() == std::get<1>(std::move(b)));
41
42 return true;
43 }
44
main(int,char **)45 int main(int, char**) {
46 test();
47 static_assert(test());
48
49 return 0;
50 }
51