binder1st (STL/CLR)
テンプレート クラスは、呼び出されたときに保存した初期引数と指定された 2 番目の引数と呼ばれる格納された 2 引数のファンクタを返す 1 引数のファンクタについて説明します。保存されたファンクタの点でそれを指定して関数オブジェクトを使用します。
template<typename Fun>
ref class binder1st
{ // wrap operator()
public:
typedef Fun stored_function_type;
typedef typename Fun::first_argument_type first_argument_type;
typedef typename Fun::second_argument_type second_argument_type;
typedef typename Fun:result_type result_type;
typedef Microsoft::VisualC::StlClr::UnaryDelegate<
second_argument_type, result_type>
delegate_type;
binder1st(Fun% functor, first_argument_type left);
binder1st(binder1st<Arg>% right);
result_type operator()(second_argument_type right);
operator delegate_type^();
};
パラメーター
- 楽しみ
保存されたファンクタの種類。
メンバー関数
型定義 |
Description |
---|---|
delegate_type |
汎用デリゲートの型。 |
first_argument_type |
ファンクタ最初の引数の型。 |
result_type |
ファンクタの結果の型。 |
second_argument_type |
ファンクタ 2 番目の引数の型。 |
stored_function_type |
ファンクタの種類。 |
メンバー |
Description |
---|---|
binder1st |
ファンクタを構築します。 |
[演算子] |
Description |
---|---|
演算子 () |
目的の関数を計算します。 |
演算子の delegate_type^ () |
デリゲートにファンクタをキャストします。 |
解説
テンプレート クラスは、 2 引数のファンクタおよび最初の引数を格納する 1 引数のファンクタについて説明します。これは、オブジェクトが関数として呼び出されると、格納された最初の引数と指定された 2 番目の引数とともに保存されたファンクタを呼び出した結果を返すように、メンバー演算子を定義します operator() 。
型が delegate_type^ です。適切に変換する関数の引数がため、オブジェクトを渡すことができます。
使用例
// cliext_binder1st.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 と機能>
名前空間: の cliext