Espaces de noms
Variantes
Affichages
Actions

std::unary_negate

De cppreference.com
< cpp‎ | utility‎ | functional

 
 
 
Objets Function
Emballages de fonction
Original:
Function wrappers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
function (C++11)
mem_fn (C++11)
bad_function_call (C++11)
Lier
Original:
Bind
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
bind (C++11)
is_bind_expression (C++11)
is_placeholder (C++11)
_1, _2, _3, ... (C++11)
Emballages de référence
Original:
Reference wrappers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
reference_wrapper (C++11)
ref
cref
(C++11)
(C++11)
Emballages opérateur
Original:
Operator wrappers
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Négateurs
Original:
Negators
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unary_negate
binary_negate
Obsolète liants et des adaptateurs
Original:
Deprecated binders and adaptors
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
unary_function (obsolète)
binary_function (obsolète)
ptr_fun (obsolète)
pointer_to_unary_function (obsolète)
pointer_to_binary_function (obsolète)
mem_fun (obsolète)
mem_fun_t
mem_fun1_t
const_mem_fun_t
const_mem_fun1_t
(obsolète)
(obsolète)
(obsolète)
(obsolète)
mem_fun_ref (obsolète)
mem_fun_ref_t
mem_fun1_ref_t
const_mem_fun_ref_t
const_mem_fun1_ref_t
(obsolète)
(obsolète)
(obsolète)
(obsolète)
binder1st
binder2nd
(obsolète)
(obsolète)
bind1st
bind2nd
(obsolète)
(obsolète)
 
Defined in header <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.
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.
unary_negate objets sont facilement construits avec fonction d'aide .. std::not1
Original:
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.

Sommaire

[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

(constructor)
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

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()

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) [edit]
(C++11)
adaptateur générique de foncteur
(classe générique) [edit]
fonction permettant de construire un objet de type std::unary_negate
(fonction générique) [edit]
(obsolète)
crée un foncteur à partir d'une fonction
(fonction générique) [edit]
(obsolète)
classe de base pour définir des foncteurs à 1 paramètre
(classe générique) [edit]