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 // explicit operator bool() const
14 
15 // This test runs in C++03, but we have deprecated using std::function in C++03.
16 // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS -D_LIBCPP_ENABLE_CXX03_FUNCTION
17 
18 #include <functional>
19 #include <cassert>
20 #include <type_traits>
21 
22 #include "test_macros.h"
23 
g(int)24 int g(int) {return 0;}
25 
main(int,char **)26 int main(int, char**)
27 {
28     static_assert(std::is_constructible<bool, std::function<void()> >::value, "");
29     static_assert(!std::is_convertible<std::function<void()>, bool>::value, "");
30 
31     {
32     std::function<int(int)> f;
33     assert(!f);
34     f = g;
35     assert(f);
36     }
37 
38   return 0;
39 }
40