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