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