std::unary_negate
De cppreference.com
< cpp | utility | functional
![]() |
This page has been machine-translated from the English version of the wiki using Google Translate.
The translation may contain errors and awkward wording. Hover over text to see the original version. You can help to fix errors and improve the translation. For instructions click here. |
Déclaré dans l'en-tête <functional>
|
||
template< class Predicate > struct unary_negate : public std::unary_function<Predicate::argument_type, bool>; |
(avant C++11) | |
template< class Predicate > struct unary_negate; |
(depuis C++11) | |
unary_negate
est un objet fonction enveloppe de retour le complément du prédicat unaire qu'il détient .Original:
unary_negate
is a 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.
You can help to correct and verify the translation. Click here for instructions.
Le type de relation unaire doit définir un type d'élément,
argument_type
, qui est convertible en type de paramètre du prédicat. Les objets de fonction unaires obtenus à partir std::ref, std::cref, std::negate, std::logical_not, std::mem_fn, std::function, std::hash, ou d'un autre appel à std::not1 ont ce type définies, de même que les objets issus de la fonction std::unary_function obsolète . 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.
unary_negate
objets sont facilement construits avec fonction d'aide .. std::not1Original:
unary_negate
objects are easily constructed with helper function std::not1.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.
[modifier] Types de membres
Type d'
Original: Type The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Definition |
argument_type
|
Predicate::argument_type |
result_type
|
bool |
[modifier] Fonctions membres
(constructeur) |
constructs a new unary_negate object with the supplied predicate (fonction membre publique) |
operator() |
renvoie le complément logique de la suite d'un appel à l'attribut stocké Original: returns the logical complement of the result of a call to the stored predicate The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (fonction membre publique) |
std :: unary_negate ::Original:std::unary_negate::The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.unary_negate
Original:
std::unary_negate::
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.
explicit unary_negate( Predicate const& pred ); |
||
Constructs a unary_negate
function object with the stored predicate pred
.
Parameters
pred | - | objet fonction de prédicat
Original: predicate function object The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
std :: unary_negate ::Original:std::unary_negate::The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.operator()
Original:
std::unary_negate::
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.
bool operator()( argument_type const& x ) const; |
||
Returns the logical complement of the result of calling pred(x).
Parameters
x | - | argument à passer à travers prédicat
Original: argument to pass through to predicate The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. |
Return value
The logical complement of the result of calling pred(x).
[modifier] Exemple
#include <algorithm> #include <functional> #include <iostream> #include <vector> struct less_than_7 : 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::unary_negate<less_than_7> not_less_than_7((less_than_7())); std::cout << std::count_if(v.begin(), v.end(), not_less_than_7); /* C++11 solution: // Use std::function<bool (int)> std::function<bool (int)> not_less_than_7 = [](int x)->bool{ return !less_than_7()(x); }; std::cout << std::count_if(v.begin(), v.end(), not_less_than_7); */ }
Résultat :
3
[modifier] Voir aussi
foncteur retournant le complémentaire d'un foncteur existant, de type prédicat binaire (classe générique) | |
(C++11) |
adaptateur générique de foncteur (classe générique) |
fonction permettant de construire un objet de type std::unary_negate (fonction générique) | |
(obsolète) |
crée un foncteur à partir d'une fonction (fonction générique) |
(obsolète) |
classe de base pour définir des foncteurs à 1 paramètre (classe générique) |