stlab.adobe.com Adobe Systems Incorporated

ptr_fun

functors.gif
function.gif
adaptors.gif
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 functors. 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.

Preconditions

Complexity

Example

See the examples in the discussions of pointer_to_unary_function and pointer_to_binary_function.

Notes

See also

functors, pointer_to_unary_function, pointer_to_binary_function, AdaptableUnaryFunction, AdaptableBinaryFunction

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google