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