bind1st [C++ Reference]
Keywords: stl,functional,bind1st
Date: 2009-03-21T22:41:01-0700

[[bind1st]]
C++ Reference
Translations of this page?:

- en
- br-pt
- cn
- cz
- de
- es
- fr
- it
- jp
- nl
- pl
- ro
- ru
- sk
- tr
- tw

## bind1st

Syntax:

      template <class Operation, class T>
        binder1st<Operation> bind1st (const Operation& op, const T& x);

bind the first argument of the binary function.

For example:

    #include <iostream>
    using std::cout;
    #include <algorithm>
    using std::transform;
    #include <functional>
    using std::bind1st;
    using std::plus;

    int main(int argc, char **argv) {
      int a1[]={0,1,2,3,4,5};
      const size_t SIZE=sizeof(a1)/sizeof(*a1);
      transform(a1,a1+SIZE,a1,bind1st(plus<int>(),SIZE));
        for(size_t i=0;i<SIZE;i++){
          cout<<a1[i]<<" ";
        }
      return EXIT_SUCCESS;
    }

Edit this page • Old revisions
• • • Login • Index • Recent changes • RSS • cc •