次の方法で共有


binder2nd (STL/CLR)

テンプレート クラスは、呼び出されたときに指定した初期引数と保存された 2 番目の引数と呼ばれる格納された 2 引数のファンクタを返す 1 引数のファンクタについて説明します。保存されたファンクタの点でそれを指定して関数オブジェクトを使用します。

template<typename Fun>
    ref class binder2nd
    { // 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<
        first_argument_type, result_type>
        delegate_type;

    binder2nd(Fun% functor, second_argument_type left);
    binder2nd(binder2nd<Arg>% right);

    result_type operator()(first_argument_type right);
    operator delegate_type^();
    };

パラメーター

  • 楽しみ
    保存されたファンクタの種類。

メンバー関数

型定義

Description

delegate_type

汎用デリゲートの型。

first_argument_type

ファンクタ最初の引数の型。

result_type

ファンクタの結果の型。

second_argument_type

ファンクタ 2 番目の引数の型。

stored_function_type

ファンクタの種類。

メンバー

Description

binder2nd

ファンクタを構築します。

[演算子]

Description

演算子 ()

目的の関数を計算します。

演算子の delegate_type^ ()

デリゲートにファンクタをキャストします。

解説

テンプレート クラスは、 2 引数のファンクタと 2 番目の引数を格納する 1 引数のファンクタについて説明します。これは、オブジェクトが関数として呼び出されると、指定した初期引数と保存された 2 番目の引数とともに保存されたファンクタを呼び出した結果を返すように、メンバー演算子を定義します operator() 。

型が delegate_type^ です。適切に変換する関数の引数がため、オブジェクトを渡すことができます。

使用例

// cliext_binder2nd.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 と機能>

名前空間: の cliext

参照

関連項目

bind2nd (STL/CLR)