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 <cassert>
16#include "test_macros.h"
17#include "test_iterators.h"
18
19template<std::ranges::subrange_kind K, class... Args>
20concept ValidSubrangeKind = requires { typename std::ranges::subrange<Args..., K>; };
21
22template<class... Args>
23concept ValidSubrange = requires { typename std::ranges::subrange<Args...>; };
24
25static_assert( ValidSubrange<forward_iterator<int*>>);
26static_assert( ValidSubrange<forward_iterator<int*>, forward_iterator<int*>>);
27static_assert( ValidSubrangeKind<std::ranges::subrange_kind::unsized, forward_iterator<int*>, forward_iterator<int*>>);
28static_assert( ValidSubrangeKind<std::ranges::subrange_kind::sized, forward_iterator<int*>, forward_iterator<int*>>);
29// Wrong sentinel type.
30static_assert(!ValidSubrange<forward_iterator<int*>, int*>);
31static_assert( ValidSubrange<int*>);
32static_assert( ValidSubrange<int*, int*>);
33// Must be sized.
34static_assert(!ValidSubrangeKind<std::ranges::subrange_kind::unsized, int*, int*>);
35static_assert( ValidSubrangeKind<std::ranges::subrange_kind::sized, int*, int*>);
36// Wrong sentinel type.
37static_assert(!ValidSubrange<int*, forward_iterator<int*>>);
38// Not an iterator.
39static_assert(!ValidSubrange<int>);
40

source code of libcxx/test/std/ranges/range.utility/range.subrange/general.compile.pass.cpp