binder2nd, bind2nd |
A unary function object that
applies a binary function to a predefined value and another operand. Use the
associated adapter function bind2nd() to
conveniently construct a binder2nd object directly
from a function and a value. This object is called binder2nd
because the operand is used as the 2nd parameter to the binary function. The
first parameter is supplied. Use binder1st if you
want the operand to be used as the first parameter.
#include <functional>
template< class Operation >
class binder2nd : public unary_function
<
typename Operation::first_argument_type,
typename Operation::result_type
>
binder2nd
object associated with operation op and value value
.( x ,
value ) .
#include <iostream>
#include <algorithm>
#include <functional>
int array[ 3 ] = { 1, 2, 3 };
void
main()
{
replace_if
(
array,
array + 3,
binder2nd< greater< int > >( greater< int >(), 2 ),
4
);
for ( int i = 0; i < 3; ++i )
cout << array[ i ] << "\n";
}
1
2
4
Copyright©1994-2026 Recursion Software LLC
All Rights Reserved - For use by licensed users only.