unary_negate (STL/CLR)
テンプレート クラスは、呼び出されたときに保存された 1 引数のファンクタの論理 OR のない返すファンクタについて説明します。保存されたファンクタの点でそれを指定して関数オブジェクトを使用します。
template<typename Fun>
ref class unary_negate
{ // wrap operator()
public:
typedef Fun stored_function_type;
typedef typename Fun::argument_type argument_type;
typedef bool result_type;
typedef Microsoft::VisualC::StlClr::UnaryDelegate<
argument_type, result_type>
delegate_type;
unary_negate(Fun% functor);
unary_negate(unary_negate<Fun>% right);
result_type operator()(argument_type left);
operator delegate_type^();
};
パラメーター
- 楽しみ
保存されたファンクタの種類。
メンバー関数
型定義 |
Description |
---|---|
argument_type |
ファンクタの引数の型。 |
delegate_type |
汎用デリゲートの型。 |
result_type |
ファンクタの結果の型。 |
メンバー |
Description |
---|---|
unary_negate |
ファンクタを構築します。 |
[演算子] |
Description |
---|---|
演算子 () |
目的の関数を計算します。 |
delegate_type^ |
デリゲートにファンクタをキャストします。 |
解説
テンプレート クラスは、別の 1 引数のファンクタを格納する 1 引数のファンクタについて説明します。これは、オブジェクトが関数として呼び出されると、引数と呼ばれる格納されたファンクタの論理 OR のない返すように、メンバー演算子を定義します operator() 。
型が delegate_type^ です。適切に変換する関数の引数がため、オブジェクトを渡すことができます。
使用例
// cliext_unary_negate.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(0);
Myvector c3(2, 0);
// display initial contents " 4 0"
for each (int elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// transform and display
cliext::logical_not<int> not_op;
cliext::transform(c1.begin(), c1.begin() + 2, c3.begin(),
cliext::unary_negate<cliext::logical_not<int> >(not_op));
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(),
cliext::not1(not_op));
for each (int elem in c3)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
return (0);
}
必要条件
ヘッダー: <cliext と機能>
名前空間: の cliext