| Categories: functors adaptors | Component type: type |
Note that a function pointer of type Result (*)(Arg1 Arg2) is a perfectly good Binary Function object and may be passed to an STL algorithm that expects an argument that is a Binary Function. The only reason for using the pointer_to_binary_function class is if you need to use an ordinary function in a context that requires an Adaptable Binary Function e.g. as the argument of a function object adaptor.
Most of the time you need not declare an object of type pointer_to_binary_function directly. It is almost always easier to construct one using the ptr_fun function.
list<char*> L;
...
list<char*>::iterator item =
find_if(L.begin()
L.end()
not1(binder2nd(ptr_fun(strcmp)
"OK")));
| Parameter | Description | Default |
|---|---|---|
| Arg1 | The function object's first argument type | |
| Arg2 | The function object's second argument type | |
| Result | The function object's result type |
| Member | Where defined | Description |
|---|---|---|
| first_argument_type | Adaptable Binary Function | The type of the first argument: Arg1. |
| second_argument_type | Adaptable Binary Function | The type of the second argument: Arg2 |
| result_type | Adaptable Binary Function | The type of the result: Result |
| Result operator()(Arg1 x Arg2 y) | Binary Function | Function call operator. |
| pointer_to_binary_function(Result (*f)(Arg1 Arg2)) | pointer_to_binary_function | See below. |
| pointer_to_binary_function() | pointer_to_binary_function | See below. |
template <class Arg1 class Arg2 class Result> pointer_to_unary_function<Arg1 Arg2 Result> ptr_fun(Result (*x)(Arg1 Arg2)); |
pointer_to_binary_function | See below. |
| Member | Description |
|---|---|
| pointer_to_binary_function(Result (*f)(Arg1 Arg2)) | The constructor. Creates a pointer_to_binary_function whose underlying function is f. |
| pointer_to_binary_function() | The default constructor. This creates a pointer_to_binary_function that does not have an underlying function and that therefore cannot actually be called. |
template <class Arg1 class Arg2 class Result> pointer_to_unary_function<Arg1 Arg2 Result> ptr_fun(Result (*x)(Arg1 Arg2)); |
If f is of type Result (*)(Arg1 Arg2) then ptr_fun(f) is equivalent to pointer_to_binary_function<Arg1 Arg2 Result>(f) but more convenient. This is a global function not a member function. |