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
22static_assert( std::is_convertible_v<ForwardSubrange, std::pair<ForwardIter, ForwardIter>>);
23static_assert( std::is_convertible_v<ForwardSubrange, std::tuple<ForwardIter, ForwardIter>>);
24static_assert(!std::is_convertible_v<ForwardSubrange, std::tuple<ForwardIter, ForwardIter>&>);
25static_assert(!std::is_convertible_v<ForwardSubrange, std::tuple<ForwardIter, ForwardIter, ForwardIter>>);
26static_assert( std::is_convertible_v<ConvertibleForwardSubrange, std::tuple<ConvertibleForwardIter, int*>>);
27static_assert(!std::is_convertible_v<SizedIntPtrSubrange, std::tuple<long*, int*>>);
28static_assert( std::is_convertible_v<SizedIntPtrSubrange, std::tuple<int*, int*>>);
29
30constexpr 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
42int main(int, char**) {
43 test();
44 static_assert(test());
45
46 return 0;
47}
48

source code of libcxx/test/std/ranges/range.utility/range.subrange/ctor.pair_like_conv.pass.cpp