Книга: Standard Template Library Programmer
ptr_fun
Разделы на этой странице:
ptr_fun
Categories: functors, adaptors
Component type: function
Prototype
template <class Arg, class Result>
pointer_to_unary_function<Arg, Result> ptr_fun(Result (*x)(Arg));
template <class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1, Arg2, Result> ptr_fun(Result (*x)(Arg1, Arg2));
Description
Ptr_fun takes a function pointer as its argument and returns a function pointer adaptor, a type of function object. It is actually two different functions, not one (that is, the name ptr_fun is overloaded). If its argument is of type Result (*)(Arg) then ptr_fun creates a pointer_to_unary_function, and if its argument is of type Result (*)(Arg1, Arg2) then ptr_fun creates a pointer_to_binary_function.
Definition
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.
Requirements on types
The argument must be a pointer to a function that takes either one or two arguments. The argument type(s) and the return type of the function are arbitrary, with the restriction that the function must return a value; it may not be a void function.
Example
See the examples in the discussions of pointer_to_unary_function and pointer_to_binary_function.
See also
Function Objects, pointer_to_unary_function, pointer_to_binary_function, Adaptable Unary Function, Adaptable Binary Function
- pointer_to_unary_function
- Совет 41. Разберитесь, для чего нужны ptr_fun, mem_fun и mem_fun_ref
- EXTERNAL FUNCTION DIRECTORY
- CHAPTER 4 Functions and Libraries in mikroC
- Them's Funky People
- Functions
- Basic Functions
- Using Functions in Shell Scripts
- 4.1 mikroC Functions
- 4.2 mikroC Built-in Functions
- 4.3 mikroC Library Functions
- 4.1.1 Function Prototypes