ptr_fun2.pass.cpp (773B)
1 //===----------------------------------------------------------------------===// 2 // 3 // The LLVM Compiler Infrastructure 4 // 5 // This file is dual licensed under the MIT and the University of Illinois Open 6 // Source Licenses. See LICENSE.TXT for details. 7 // 8 //===----------------------------------------------------------------------===// 9 10 // <functional> 11 // REQUIRES: c++98 || c++03 || c++11 || c++14 12 13 // template <CopyConstructible Arg1, CopyConstructible Arg2, Returnable Result> 14 // pointer_to_binary_function<Arg1,Arg2,Result> 15 // ptr_fun(Result (*f)(Arg1, Arg2)); 16 17 #include <functional> 18 #include <type_traits> 19 #include <cassert> 20 21 double binary_f(int i, short j) {return i - j + .75;} 22 23 int main() 24 { 25 assert(std::ptr_fun(binary_f)(36, 27) == 9.75); 26 }