1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
11 // constexpr explicit repeat_view(const T& value, Bound bound = Bound()) requires copy_constructible<T>;
12 // constexpr explicit repeat_view(T&& value, Bound bound = Bound());
17 #include <type_traits>
24 static_assert(std::is_constructible_v
<std::ranges::repeat_view
<Empty
>, const Empty
&>);
25 static_assert(std::is_constructible_v
<std::ranges::repeat_view
<Empty
>, Empty
&&>);
26 static_assert(std::is_constructible_v
<std::ranges::repeat_view
<Empty
, int>, const Empty
&>);
27 static_assert(std::is_constructible_v
<std::ranges::repeat_view
<Empty
, int>, Empty
&&>);
29 static_assert(!std::is_convertible_v
<const Empty
&, std::ranges::repeat_view
<Empty
>>);
30 static_assert(!std::is_convertible_v
<Empty
&&, std::ranges::repeat_view
<Empty
>>);
31 static_assert(!std::is_convertible_v
<const Empty
&, std::ranges::repeat_view
<Empty
, int>>);
32 static_assert(!std::is_convertible_v
<Empty
&&, std::ranges::repeat_view
<Empty
, int>>);
34 static_assert(!std::is_constructible_v
<std::ranges::repeat_view
<MoveOnly
>, const MoveOnly
&>);
35 static_assert(std::is_constructible_v
<std::ranges::repeat_view
<MoveOnly
>, MoveOnly
&&>);
37 constexpr bool test() {
38 // Move && unbound && default argument
40 std::ranges::repeat_view
<Empty
> rv(Empty
{});
41 assert(rv
.begin() + 10 != rv
.end());
44 // Move && unbound && user-provided argument
46 std::ranges::repeat_view
<Empty
> rv(Empty
{}, std::unreachable_sentinel
);
47 assert(rv
.begin() + 10 != rv
.end());
50 // Move && bound && default argument
52 std::ranges::repeat_view
<Empty
, int> rv(Empty
{});
53 assert(rv
.begin() == rv
.end());
56 // Move && bound && user-provided argument
58 std::ranges::repeat_view
<Empty
, int> rv(Empty
{}, 10);
59 assert(rv
.begin() + 10 == rv
.end());
62 // Copy && unbound && default argument
65 std::ranges::repeat_view
<Empty
> rv(e
);
66 assert(rv
.begin() + 10 != rv
.end());
69 // Copy && unbound && user-provided argument
72 std::ranges::repeat_view
<Empty
> rv(e
, std::unreachable_sentinel
);
73 assert(rv
.begin() + 10 != rv
.end());
76 // Copy && bound && default argument
79 std::ranges::repeat_view
<Empty
, int> rv(e
);
80 assert(rv
.begin() == rv
.end());
83 // Copy && bound && user-provided argument
86 std::ranges::repeat_view
<Empty
, int> rv(e
, 10);
87 assert(rv
.begin() + 10 == rv
.end());
93 int main(int, char**) {
95 static_assert(test());