Nugget
|
#include <functional.h>
Public Member Functions | |
pointer_to_unary_function (Result(*pFunction)(Arg)) | |
Result | operator() (Arg x) const |
Protected Attributes | |
Result(* | mpFunction )(Arg) |
Additional Inherited Members | |
Public Types inherited from eastl::unary_function< Arg, Result > | |
typedef Arg | argument_type |
typedef Result | result_type |
This is an adapter template which converts a pointer to a standalone function to a function object. This allows standalone functions to work in many cases where the system requires a function object.
Example usage: ptrdiff_t Rand(ptrdiff_t n) { return rand() % n; } // Note: The C rand function is poor and slow. pointer_to_unary_function<ptrdiff_t, ptrdiff_t> randInstance(Rand); random_shuffle(pArrayBegin, pArrayEnd, randInstance);