174fd3cb8SChristopher Di Bella //===----------------------------------------------------------------------===//
274fd3cb8SChristopher Di Bella //
374fd3cb8SChristopher Di Bella // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
474fd3cb8SChristopher Di Bella // See https://llvm.org/LICENSE.txt for license information.
574fd3cb8SChristopher Di Bella // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
674fd3cb8SChristopher Di Bella //
774fd3cb8SChristopher Di Bella //===----------------------------------------------------------------------===//
874fd3cb8SChristopher Di Bella 
974fd3cb8SChristopher Di Bella // UNSUPPORTED: c++03, c++11, c++14, c++17
10*71909de3SMark de Wever // UNSUPPORTED: libcpp-has-no-incomplete-ranges
1174fd3cb8SChristopher Di Bella 
1274fd3cb8SChristopher Di Bella // std::ranges::dangling;
1374fd3cb8SChristopher Di Bella 
1474fd3cb8SChristopher Di Bella #include <ranges>
1574fd3cb8SChristopher Di Bella 
1674fd3cb8SChristopher Di Bella #include <concepts>
1774fd3cb8SChristopher Di Bella #include <type_traits>
1874fd3cb8SChristopher Di Bella 
1974fd3cb8SChristopher Di Bella static_assert(std::is_empty_v<std::ranges::dangling>);
2074fd3cb8SChristopher Di Bella 
2174fd3cb8SChristopher Di Bella template<int> struct S { };
2274fd3cb8SChristopher Di Bella static_assert(std::is_nothrow_constructible_v<std::ranges::dangling>);
2374fd3cb8SChristopher Di Bella static_assert(std::is_nothrow_constructible_v<std::ranges::dangling, S<0>>);
2474fd3cb8SChristopher Di Bella static_assert(std::is_nothrow_constructible_v<std::ranges::dangling, S<0>, S<1>>);
2574fd3cb8SChristopher Di Bella static_assert(std::is_nothrow_constructible_v<std::ranges::dangling, S<0>, S<1>, S<2>>);
2674fd3cb8SChristopher Di Bella 
test_dangling()2774fd3cb8SChristopher Di Bella constexpr bool test_dangling() {
2874fd3cb8SChristopher Di Bella   [[maybe_unused]] auto a = std::ranges::dangling();
2974fd3cb8SChristopher Di Bella   [[maybe_unused]] auto b = std::ranges::dangling(S<0>());
3074fd3cb8SChristopher Di Bella   [[maybe_unused]] auto c = std::ranges::dangling(S<0>(), S<1>());
3174fd3cb8SChristopher Di Bella   [[maybe_unused]] auto d = std::ranges::dangling(S<0>(), S<1>(), S<2>());
3274fd3cb8SChristopher Di Bella   return true;
3374fd3cb8SChristopher Di Bella }
3474fd3cb8SChristopher Di Bella 
main(int,char **)3574fd3cb8SChristopher Di Bella int main(int, char**) {
3674fd3cb8SChristopher Di Bella   static_assert(test_dangling());
3774fd3cb8SChristopher Di Bella   test_dangling();
3874fd3cb8SChristopher Di Bella   return 0;
3974fd3cb8SChristopher Di Bella }
40