bind2nd (STL/CLR) Home
This page is specific to:.NET Framework Version:3.54.0
Visual Studio 2010 - Visual C++
bind2nd (STL/CLR)

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Generates a binder2nd for an argument and functor.

template<typename Fun,
    typename Arg>
    binder2nd<Fun> bind2nd(Fun% functor,
        Arg right);
Template Parameters

Arg

The type of the argument.

Fun

The type of the functor.

Function Parameters

functor

The functor to wrap.

right

The second argument to wrap.

Remarks

The template function returns binder2nd (STL/CLR)<Fun>(functor, right). You use it as a convenient way to wrap a two-argument functor and its second argument in a one-argument functor that calls it with a first argument.

Example

// cliext_bind2nd.cpp 
// compile with: /clr 
#include <cliext/algorithm> 
#include <cliext/functional> 
#include <cliext/vector> 
 
typedef cliext::vector<int> Myvector; 
int main() 
    { 
    Myvector c1; 
    c1.push_back(4); 
    c1.push_back(3); 
    Myvector c3(2, 0); 
 
// display initial contents " 4 3" 
    for each (int elem in c1) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// transform and display 
    cliext::minus<int> sub_op; 
    cliext::binder2nd<cliext::minus<int> > sub4(sub_op, 4); 
 
    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(), 
        sub4); 
    for each (int elem in c3) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
 
// transform and display with function 
    cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(), 
        bind2nd(sub_op, 4)); 
    for each (int elem in c3) 
        System::Console::Write(" {0}", elem); 
    System::Console::WriteLine(); 
    return (0); 
    } 
 
 4 3
 0 -1
 0 -1
Requirements

Header: <cliext/functional>

Namespace: cliext

See Also

Reference

© 2009 Microsoft Corporation. All rights reserved.   Terms of Use | Trademarks | Privacy Statement
Page view tracker
Rate the Lightweight library
x
Lightweight builds on ScriptFree (loband) by adding features you've requested: a SearchBox and default code language selection.
Do you like the SearchBox?
Do you like the tabbed code blocks?
How useful is this topic?
Tell us more.
Thanks
x
You're helping to improve MSDN Online.
Feedback
Switch View
Classic
Lightweight Beta
ScriptFree
Switch View