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