std::not1
提供: cppreference.com
< cpp | utility | functional
|
|
このページは、Google 翻訳を使って英語版から機械翻訳されました。
翻訳には誤りや奇妙な言い回しがあるかもしれません。文章の上にポインタをおくと、元の文章が見れます。誤りを修正して翻訳を改善する手助けをしてください。翻訳についての説明は、ここをクリックしてください。 |
| Defined in header <functional>
|
||
| template< class Predicate > std::unary_negate<Predicate> not1(const Predicate& pred); |
||
not1渡さ単項述語関数の補数を返す関数オブジェクトを作成するためのヘルパー関数です。作成した関数オブジェクトは型std::unary_negate<Predicate>のです.Original:
not1 is a helper function to create a function object that returns the complement of the unary predicate function passed. The function object created is of type std::unary_negate<Predicate>.The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
単項述語のタイプは、メンバータイプ、述部のパラメーター·タイプに変換可能である
argument_typeを定義する必要があります。 std::refから得単項関数オブジェクト、std::cref、std::negate、std::logical_not、std::mem_fn、std::function、std::hash、または別の呼び出しからstd::not1非推奨std::unary_functionから派生した関数オブジェクトがあるので、このタイプは、定義されている. Original:
The unary predicate type must define a member type,
argument_type, that is convertible to the predicate's parameter type. The unary function objects obtained from std::ref, std::cref, std::negate, std::logical_not, std::mem_fn, std::function, std::hash, or from another call to std::not1 have this type defined, as are function objects derived from the deprecated std::unary_function. The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
目次 |
[編集] パラメータ
| pred | - | 単項述語
Original: unary predicate The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
[編集] 値を返します
std::not1std::unary_negate<Predicate>で構築、型predのオブジェクトを返します。.Original:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例外
なし.
Original:
None.
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
You can help to correct and verify the translation. Click here for instructions.
[編集] 例
このコードを実行します
#include <algorithm> #include <functional> #include <iostream> #include <vector> struct LessThan7 : std::unary_function<int, bool> { bool operator()(int i) const { return i < 7; } }; int main() { std::vector<int> v; for (int i = 0; i < 10; ++i) { v.push_back(i); } std::cout << std::count_if(v.begin(), v.end(), std::not1(LessThan7())) << "\n"; //same as above, but use a lambda function std::function<int(int)> less_than_9 = [](int x){ return x < 9; }; std::cout << std::count_if(v.begin(), v.end(), std::not1(less_than_9)) << "\n"; }
出力:
3
[編集] 参照
| ラッパー関数オブジェクトは、それが保持単項述語の補集合を返す Original: wrapper function object returning the complement of the unary predicate it holds The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) | |
| (C++11) |
指定された関数呼び出しシグネチャを持つ任意の型の呼び出し可能オブジェクトをラップします Original: wraps callable object of any type with specified function call signature The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |
| カスタムstd::binary_negateオブジェクトを作成します Original: constructs custom std::binary_negate object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) | |
| (廃止予定) |
関数へのポインタからアダプタと互換性のある関数オブジェクトのラッパーを作成します Original: creates an adaptor-compatible function object wrapper from a pointer to function The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (関数テンプレート) |
| (廃止予定) |
アダプタと互換性の単項関数基底クラス Original: adaptor-compatible unary function base class The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (クラステンプレート) |