| 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 |
// template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result> |
| 12 |
// pointer_to_binary_function<Arg1,Arg2,Result> |
| 13 |
// ptr_fun(Result (*f)(Arg1, Arg2)); |
| 14 |
|
| 15 |
// REQUIRES: c++03 || c++11 || c++14 |
| 16 |
// ADDITIONAL_COMPILE_FLAGS: -D_LIBCPP_DISABLE_DEPRECATION_WARNINGS |
| 17 |
|
| 18 |
#include <functional> |
| 19 |
#include <type_traits> |
| 20 |
#include <cassert> |
| 21 |
|
| 22 |
#include "test_macros.h" |
| 23 |
|
| 24 |
double binary_f(int i, short j) {return i - j + .75;} |
| 25 |
|
| 26 |
int main(int, char**) |
| 27 |
{ |
| 28 |
assert(std::ptr_fun(binary_f)(36, 27) == 9.75); |
| 29 |
|
| 30 |
return 0; |
| 31 |
} |