xref: /llvm-project/libcxx/test/std/utilities/function.objects/func.not_fn/not_fn.nttp.verify.cpp (revision c91d805e6627987bec8ec34ea67c1e8240940039)
1*c91d805eSJakub Mazurkiewicz //===----------------------------------------------------------------------===//
2*c91d805eSJakub Mazurkiewicz //
3*c91d805eSJakub Mazurkiewicz // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*c91d805eSJakub Mazurkiewicz // See https://llvm.org/LICENSE.txt for license information.
5*c91d805eSJakub Mazurkiewicz // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*c91d805eSJakub Mazurkiewicz //
7*c91d805eSJakub Mazurkiewicz //===----------------------------------------------------------------------===//
8*c91d805eSJakub Mazurkiewicz 
9*c91d805eSJakub Mazurkiewicz // UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
10*c91d805eSJakub Mazurkiewicz 
11*c91d805eSJakub Mazurkiewicz // <functional>
12*c91d805eSJakub Mazurkiewicz 
13*c91d805eSJakub Mazurkiewicz // template<auto f> constexpr unspecified not_fn() noexcept;
14*c91d805eSJakub Mazurkiewicz // Mandates: If is_pointer_v<F> || is_member_pointer_v<F> is true, then f != nullptr is true.
15*c91d805eSJakub Mazurkiewicz 
16*c91d805eSJakub Mazurkiewicz #include <functional>
17*c91d805eSJakub Mazurkiewicz 
18*c91d805eSJakub Mazurkiewicz struct X {};
19*c91d805eSJakub Mazurkiewicz 
20*c91d805eSJakub Mazurkiewicz void test() {
21*c91d805eSJakub Mazurkiewicz   auto not_fn1 = std::not_fn<static_cast<bool (*)()>(nullptr)>();
22*c91d805eSJakub Mazurkiewicz   // expected-error@*:* {{static assertion failed due to requirement 'nullptr != nullptr': f cannot be equal to nullptr}}
23*c91d805eSJakub Mazurkiewicz 
24*c91d805eSJakub Mazurkiewicz   auto not_fn2 = std::not_fn<static_cast<bool X::*>(nullptr)>();
25*c91d805eSJakub Mazurkiewicz   // expected-error@*:* {{static assertion failed due to requirement 'nullptr != nullptr': f cannot be equal to nullptr}}
26*c91d805eSJakub Mazurkiewicz 
27*c91d805eSJakub Mazurkiewicz   auto not_fn3 = std::not_fn<static_cast<bool (X::*)()>(nullptr)>();
28*c91d805eSJakub Mazurkiewicz   // expected-error@*:* {{static assertion failed due to requirement 'nullptr != nullptr': f cannot be equal to nullptr}}
29*c91d805eSJakub Mazurkiewicz }
30