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 // <functional>
10
11 // class function<R(ArgTypes...)>
12
13 // template <MoveConstructible R, MoveConstructible ... ArgTypes>
14 // bool operator==(const function<R(ArgTypes...)>&, nullptr_t);
15 //
16 // template <MoveConstructible R, MoveConstructible ... ArgTypes>
17 // bool operator==(nullptr_t, const function<R(ArgTypes...)>&);
18 //
19 // template <MoveConstructible R, MoveConstructible ... ArgTypes>
20 // bool operator!=(const function<R(ArgTypes...)>&, nullptr_t);
21 //
22 // template <MoveConstructible R, MoveConstructible ... ArgTypes>
23 // bool operator!=(nullptr_t, const function<R(ArgTypes...)>&);
24
25 // This test runs in C++03, but we have deprecated using std::function in C++03.
26 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
27
28 #include <functional>
29 #include <cassert>
30
31 #include "test_macros.h"
32
g(int)33 int g(int) {return 0;}
34
main(int,char **)35 int main(int, char**)
36 {
37 {
38 std::function<int(int)> f;
39 assert(f == nullptr);
40 assert(nullptr == f);
41 f = g;
42 assert(f != nullptr);
43 assert(nullptr != f);
44 }
45
46 return 0;
47 }
48