std::ptr_fun - cppreference.com (original) (raw)

Defined in header
template< class Arg, class Result > std::pointer_to_unary_function<Arg,Result> ptr_fun( Result (*f)(Arg) ); (1) (deprecated in C++11) (removed in C++17)
template< class Arg1, class Arg2, class Result > std::pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun( Result (*f)(Arg1, Arg2) ); (2) (deprecated in C++11) (removed in C++17)

Creates a function wrapper object (either std::pointer_to_unary_function or std::pointer_to_binary_function), deducing the target type from the template arguments.

This function and the related types are deprecated as of C++11 in favor of the more general std::function and std::ref, both of which create callable adaptor-compatible function objects from plain functions.

[edit] Parameters

f - pointer to a function to create a wrapper for

[edit] Return value

A function object wrapping f.

[edit] Exceptions

May throw implementation-defined exceptions.

[edit] Example

[edit] See also

| | copyable wrapper of any copy constructible callable object (class template) [edit] | | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | move-only wrapper of any callable object that supports qualifiers in a given call signature (class template) [edit] | | | invokes any Callable object with given arguments and possibility to specify return type(since C++23) (function template) [edit] | | | creates a function object that returns the complement of the result of the function object it holds (function template) [edit] |