xref: /llvm-project/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.nttp.verify.cpp (revision c91d805e6627987bec8ec34ea67c1e8240940039)
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, c++20, c++23
10 
11 // <functional>
12 
13 // template<auto f> constexpr unspecified not_fn() noexcept;
14 // Mandates: If is_pointer_v<F> || is_member_pointer_v<F> is true, then f != nullptr is true.
15 
16 #include <functional>
17 
18 struct X {};
19 
20 void test() {
21   auto not_fn1 = std::not_fn<static_cast<bool (*)()>(nullptr)>();
22   // expected-error@*:* {{static assertion failed due to requirement 'nullptr != nullptr': f cannot be equal to nullptr}}
23 
24   auto not_fn2 = std::not_fn<static_cast<bool X::*>(nullptr)>();
25   // expected-error@*:* {{static assertion failed due to requirement 'nullptr != nullptr': f cannot be equal to nullptr}}
26 
27   auto not_fn3 = std::not_fn<static_cast<bool (X::*)()>(nullptr)>();
28   // expected-error@*:* {{static assertion failed due to requirement 'nullptr != nullptr': f cannot be equal to nullptr}}
29 }
30