bind2nd

Syntax:

  template <class Operation, class T>
    binder2nd<Operation> bind2nd (const Operation& op, const T& x);

bind the second argument of the binary function.

For example:

#include <iostream>
using std::cout;
using std::endl;
using std::boolalpha;
#include <algorithm>
using std::transform;
#include <functional>
using std::bind2nd;
using std::less;
 
int main(int argc, char **argv) {
  int a1[]= {0,1,2,3,4,5};
  const size_t SIZE= sizeof(a1) / sizeof(*a1);
  bool is_less[SIZE] = {false};
  transform(a1, a1+SIZE, is_less, bind2nd(less<int>(), 3));
  for(size_t i=0; i<SIZE; i++){
    cout << a1[i] << " < 3 :"<< boolalpha << is_less[i] << endl;;
  }
  return EXIT_SUCCESS;
}