| 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 Arg, Returnable Result> |
| 12 |
// pointer_to_unary_function<Arg, Result> |
| 13 |
// ptr_fun(Result (*f)(Arg)); |
| 14 |
|
| 15 |
// UNSUPPORTED: 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 unary_f(int i) {return 0.5 - i;} |
| 25 |
|
| 26 |
int main(int, char**) |
| 27 |
{ |
| 28 |
assert(std::ptr_fun(unary_f)(36) == -35.5); |
| 29 |
|
| 30 |
return 0; |
| 31 |
} |