Rogue Wave banner
Previous fileTop of documentContentsIndexNext file

ptr_fun


Function Adaptor

Summary

A function that is overloaded to adapt a pointer to a function, to take the place of a function.

Data Type and Member Function Indexes
(exclusive of constructors and destructors)

None

Synopsis

#include <functional>
template<class Arg, class Result>
pointer_to_unary_function<Arg, Result>
  ptr_fun (Result (*f)(Arg));

template<class Arg1, class Arg2, class Result>
pointer_to_binary_function<Arg1, Arg2, Result>
  ptr_fun (Result (*x)(Arg1, Arg2));

Description

The pointer_to_unary_function and pointer_to_binary_function classes encapsulate pointers to functions and use operator() so that the resulting object serves as a function object for the function.

The ptr_fun function is overloaded to create instances of pointer_to_unary_function or pointer_to_binary_function when included with the appropriate pointer to a function.

Example

Program Output

Warnings

If your compiler does not support default template parameters, you always need to supply the Allocator template argument. For instance, you need to write:

vector<int, allocator<int> >

instead of:

vector<int>

If your compiler does not support namespaces, then you do not need the using declaration for std.

See Also

Function Objects, pointer_to_binary_function, pointer_to_unary_function



Previous fileTop of documentContentsIndexNext file
©Copyright 1998, Rogue Wave Software, Inc.
Send mail to report errors or comment on the documentation.
OEM Release, June 1998