std::not1
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 > std::unary_negate<Predicate> not1(const Predicate& pred); | ||
not1
est une fonction d'assistance pour créer un objet fonction qui renvoie le complément de la fonction de prédicat unaire passé. L'objet créé est fonction du type de 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.
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.
Sommaire |
[modifier]Paramètres
pred | - | prédicat unaire 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. |
[modifier]Retourne la valeur
std::not1
retourne un objet de std::unary_negate<Predicate> type, construits avec 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.
[modifier]Exceptions
Aucun .
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.
[modifier]Exemple
#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 functionstd::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";}
Résultat :
3
[modifier]Voir aussi
foncteur retournant le complémentaire d'un foncteur existant, de type prédicat unaire (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::binary_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) |