binary_negate (STL/CLR)
樣板類別將告訴您 functor,呼叫時,會傳回邏輯不屬於其預存的兩個引數 functor。 使用指定的預存的 functor 的角度來看一個函式物件。
template<typename Fun>
ref class binary_negate
{ // 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 bool result_type;
typedef Microsoft::VisualC::StlClr::BinaryDelegate<
first_argument_type, second_argument_type, result_type>
delegate_type;
explicit binary_negate(Fun% functor);
binary_negate(binary_negate<Arg>% right);
result_type operator()(first_argument_type left,
second_argument_type right);
operator delegate_type^();
};
參數
- 娛樂特區
預存的 functor 型別。
成員函式
型別定義 |
描述 |
---|---|
delegate_type |
泛型委派型別。 |
first_argument_type |
Functor 的第一個引數型別。 |
result_type |
Functor 結果的型別。 |
second_argument_type |
Functor 的第二個引數的型別。 |
stored_function_type |
Functor 型別。 |
成員 |
描述 |
---|---|
binary_negate |
建構的 functor。 |
運算子 |
描述 |
---|---|
operator) |
計算所需的函式。 |
運算子 delegate_type^() |
轉換成委派 functor。 |
備註
樣板類別描述儲存其他兩個引數的 functor 引數的兩個 functor。 它定義了成員運算子operator()這麼一來,該物件做為函式呼叫時,它會傳回邏輯不是預存的 functor 呼叫兩個引數。
您也可以傳遞物件做為函式引數,其型別是delegate_type^ ,它會被適當地進行轉換。
範例
// cliext_binary_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(3);
Myvector c2;
c2.push_back(4);
c2.push_back(4);
Myvector c3(2, 0);
// display initial contents " 4 3" and " 4 4"
for each (int elem in c1)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
for each (int elem in c2)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
// transform and display
cliext::less<int> less_op;
cliext::transform(c1.begin(), c1.begin() + 2,
c2.begin(), c3.begin(),
cliext::binary_negate<cliext::less<int> >(less_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,
c2.begin(), c3.begin(), cliext::not2(less_op));
for each (int elem in c3)
System::Console::Write(" {0}", elem);
System::Console::WriteLine();
return (0);
}
需求
標頭: < cliext/功能 >
Namespace: cliext