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 | // pointer_to_unary_function |
12 | |
13 | // REQUIRES: c++03 || c++11 || c++14 |
14 | // ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
15 | |
16 | #include <functional> |
17 | #include <type_traits> |
18 | #include <cassert> |
19 | |
20 | #include "test_macros.h" |
21 | |
22 | double unary_f(int i) {return 0.5 - i;} |
23 | |
24 | int main(int, char**) |
25 | { |
26 | typedef std::pointer_to_unary_function<int, double> F; |
27 | static_assert((std::is_base_of<std::unary_function<int, double>, F>::value), "" ); |
28 | const F f(unary_f); |
29 | assert(f(36) == -35.5); |
30 | |
31 | return 0; |
32 | } |
33 | |