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 // Test the libc++-specific behavior that we handle the IFNDR case for ranges::end
12 // by being SFINAE-friendly.
13 
14 #include <cassert>
15 #include <ranges>
16 #include <type_traits>
17 #include <utility>
18 
19 struct Incomplete;
20 
test()21 constexpr bool test()
22 {
23     {
24     extern Incomplete bounded[10];
25     assert((!std::is_invocable_v<decltype(std::ranges::end), decltype((bounded))>));
26     assert((!std::is_invocable_v<decltype(std::ranges::cend), decltype((bounded))>));
27     assert((!std::is_invocable_v<decltype(std::ranges::end), decltype(std::as_const(bounded))>));
28     assert((!std::is_invocable_v<decltype(std::ranges::cend), decltype(std::as_const(bounded))>));
29     }
30     {
31     extern Incomplete unbounded[];
32     assert((!std::is_invocable_v<decltype(std::ranges::end), decltype((unbounded))>));
33     assert((!std::is_invocable_v<decltype(std::ranges::cend), decltype((unbounded))>));
34     assert((!std::is_invocable_v<decltype(std::ranges::end), decltype(std::as_const(unbounded))>));
35     assert((!std::is_invocable_v<decltype(std::ranges::cend), decltype(std::as_const(unbounded))>));
36     }
37 
38     return true;
39 }
40 
main(int,char **)41 int main(int, char**)
42 {
43     test();
44     static_assert(test());
45     return 0;
46 }
47