bind1st (STL/CLR)
會產生binder1st的引數,以及 functor。
template<typename Fun,
typename Arg>
binder1st<Fun> bind1st(Fun% functor,
Arg left);
Template Parameters
引數
引數型別。娛樂特區
Functor 型別。
函式參數
functor
若要自動換行 functor。left
若要自動換行的第一個引數。
備註
樣板函式會傳回binder1st (STL/CLR)<Fun>(functor, left)。 您可以使用它以包裝兩個引數 functor,其第一個引數中包含第二個引數呼叫它的引數 functor 最方便的方法。
範例
// 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);
}
需求
標頭: < cliext/功能 >
Namespace: cliext