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
20 // Can't invoke without arguments.
21 static_assert(!std::is_invocable_v
<decltype((std::views::single
))>);
22 #if _LIBCPP_STD_VER >= 23
23 // Can invoke with a move-only type.
24 static_assert(std::is_invocable_v
<decltype((std::views::single
)), MoveOnly
>);
26 constexpr bool test() {
30 std::same_as
<std::ranges::single_view
<int>> decltype(auto) v
= std::views::single(x
);
31 assert(v
.size() == 1);
32 assert(v
.front() == x
);
37 std::same_as
<std::ranges::single_view
<int>> decltype(auto) v
= std::views::single(42);
38 assert(v
.size() == 1);
39 assert(v
.front() == 42);
45 std::same_as
<std::ranges::single_view
<int>> decltype(auto) v
= std::views::single(x
);
46 assert(v
.size() == 1);
47 assert(v
.front() == x
);
53 std::same_as
<std::ranges::single_view
<int>> decltype(auto) v
= std::views::single(std::move(x
));
54 assert(v
.size() == 1);
55 assert(v
.front() == x
);
61 int main(int, char**) {
63 static_assert(test());