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