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 | // std::ranges::dangling; |
12 | |
13 | #include <ranges> |
14 | |
15 | #include <concepts> |
16 | #include <type_traits> |
17 | |
18 | static_assert(std::is_empty_v<std::ranges::dangling>); |
19 | |
20 | template<int> struct S { }; |
21 | static_assert(std::is_nothrow_constructible_v<std::ranges::dangling>); |
22 | static_assert(std::is_nothrow_constructible_v<std::ranges::dangling, S<0>>); |
23 | static_assert(std::is_nothrow_constructible_v<std::ranges::dangling, S<0>, S<1>>); |
24 | static_assert(std::is_nothrow_constructible_v<std::ranges::dangling, S<0>, S<1>, S<2>>); |
25 | |
26 | constexpr bool test_dangling() { |
27 | [[maybe_unused]] auto a = std::ranges::dangling(); |
28 | [[maybe_unused]] auto b = std::ranges::dangling(S<0>()); |
29 | [[maybe_unused]] auto c = std::ranges::dangling(S<0>(), S<1>()); |
30 | [[maybe_unused]] auto d = std::ranges::dangling(S<0>(), S<1>(), S<2>()); |
31 | return true; |
32 | } |
33 | |
34 | int main(int, char**) { |
35 | static_assert(test_dangling()); |
36 | test_dangling(); |
37 | return 0; |
38 | } |
39 | |