bind1st (STL/CLR)
Visual Studio 2015
The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.
The latest version of this topic can be found at bind1st (STL/CLR).
Generates a binder1st for an argument and functor.
template<typename Fun,
typename Arg>
binder1st<Fun> bind1st(Fun% functor,
Arg left);
Arg
The type of the argument.
Fun
The type of the functor.
functor
The functor to wrap.
left
The first argument to wrap.
The template function returns binder1st (STL/CLR)<Fun>(functor, left). You use it as a convenient way to wrap a two-argument functor and its first argument in a one-argument functor that calls it with a second argument.
// cliext_bind1st.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::binder1st<cliext::minus<int> > subfrom3(sub_op, 3);
cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(),
subfrom3);
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(),
bind1st(sub_op, 3));
for each (int elem in c3)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
return (0);
}
4 3 -1 0 -1 0
Header: <cliext/functional>
Namespace: cliext
Show: