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 | |
11 | // class std::ranges::subrange; |
12 | |
13 | #include <ranges> |
14 | |
15 | #include "types.h" |
16 | #include <cassert> |
17 | #include "test_macros.h" |
18 | #include "test_iterators.h" |
19 | #include <tuple> |
20 | #include <utility> |
21 | |
22 | static_assert( std::is_convertible_v<ForwardSubrange, std::pair<ForwardIter, ForwardIter>>); |
23 | static_assert( std::is_convertible_v<ForwardSubrange, std::tuple<ForwardIter, ForwardIter>>); |
24 | static_assert(!std::is_convertible_v<ForwardSubrange, std::tuple<ForwardIter, ForwardIter>&>); |
25 | static_assert(!std::is_convertible_v<ForwardSubrange, std::tuple<ForwardIter, ForwardIter, ForwardIter>>); |
26 | static_assert( std::is_convertible_v<ConvertibleForwardSubrange, std::tuple<ConvertibleForwardIter, int*>>); |
27 | static_assert(!std::is_convertible_v<SizedIntPtrSubrange, std::tuple<long*, int*>>); |
28 | static_assert( std::is_convertible_v<SizedIntPtrSubrange, std::tuple<int*, int*>>); |
29 | |
30 | constexpr bool test() { |
31 | ForwardSubrange a(ForwardIter(globalBuff), ForwardIter(globalBuff + 8)); |
32 | std::pair<ForwardIter, ForwardIter> aPair = a; |
33 | assert(base(aPair.first) == globalBuff); |
34 | assert(base(aPair.second) == globalBuff + 8); |
35 | std::tuple<ForwardIter, ForwardIter> aTuple = a; |
36 | assert(base(std::get<0>(aTuple)) == globalBuff); |
37 | assert(base(std::get<1>(aTuple)) == globalBuff + 8); |
38 | |
39 | return true; |
40 | } |
41 | |
42 | int main(int, char**) { |
43 | test(); |
44 | static_assert(test()); |
45 | |
46 | return 0; |
47 | } |
48 | |