|
| 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, c++20 |
| 10 | + |
| 11 | +// <generator> |
| 12 | + |
| 13 | +// template<class Ref, class V = void, class Allocator = void> |
| 14 | +// class generator; |
| 15 | + |
| 16 | +#include <generator> |
| 17 | + |
| 18 | +#include <cassert> |
| 19 | +#include <concepts> |
| 20 | +#include <ranges> |
| 21 | +#include <type_traits> |
| 22 | + |
| 23 | +template <class G, class V, class R, class RR> |
| 24 | +constexpr bool conformance() { |
| 25 | + static_assert(std::ranges::range<G>); |
| 26 | + static_assert(std::ranges::view<G>); |
| 27 | + static_assert(std::ranges::input_range<G>); |
| 28 | + static_assert(!std::ranges::forward_range<G>); |
| 29 | + static_assert(!std::ranges::borrowed_range<G>); |
| 30 | + |
| 31 | + static_assert(std::same_as<std::ranges::range_value_t<G>, V>); |
| 32 | + static_assert(std::same_as<std::ranges::range_reference_t<G>, R>); |
| 33 | + static_assert(std::same_as<std::ranges::range_rvalue_reference_t<G>, RR>); |
| 34 | + |
| 35 | + return true; |
| 36 | +} |
| 37 | + |
| 38 | +static_assert(conformance<std::generator<int>, int, int&&, int&&>()); |
| 39 | +static_assert(conformance<std::generator<int, int>, int, int, int>()); |
| 40 | + |
| 41 | +static_assert(conformance<std::generator<int&>, int, int&, int&&>()); |
| 42 | +static_assert(conformance<std::generator<int&, int>, int, int&, int&&>()); |
| 43 | +static_assert(conformance<std::generator<const int&>, int, const int&, const int&&>()); |
| 44 | +static_assert(conformance<std::generator<const int&, int>, int, const int&, const int&&>()); |
| 45 | + |
| 46 | +static_assert(conformance<std::generator<int&&>, int, int&&, int&&>()); |
| 47 | +static_assert(conformance<std::generator<int&&, int>, int, int&&, int&&>()); |
| 48 | +static_assert(conformance<std::generator<const int&&>, int, const int&&, const int&&>()); |
| 49 | +static_assert(conformance<std::generator<const int&&, int>, int, const int&&, const int&&>()); |
0 commit comments