std::list::empty — cppreference.com
De cppreference.com
<metanoindex/>
<tbody> </tbody>
Vérifie si le conteneur n'a pas d'éléments, à savoir si begin() == end() .
Original:
Checks if the container has no elements, i.e. whether begin() == end().
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Paramètres
(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.
Retourne la valeur
true si le récipient est vide, sinon false
Original:
true if the container is empty, false otherwise
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exceptions
Complexité
Constante
Original:
Constant
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
Exemple
Le code suivant utilise empty pour vérifier si un std::list<int> contient des éléments:
Original:
The following code uses empty to check if a std::list<int> contains any elements:
The text has been machine-translated via Google Translate.
You can help to correct and verify the translation. Click here for instructions.
#include <list> #include <iostream> int main() { std::list<int> numbers; std::cout << "Initially, numbers.empty(): " << numbers.empty() << '\n'; numbers.push_back(42); numbers.push_back(13317); std::cout << "After adding elements, numbers.empty(): " << numbers.empty() << '\n'; }
Résultat :
Initially, numbers.empty(): 1 After adding elements, numbers.empty(): 0
See also
retourne le nombre d'éléments Original: returns the number of elements The text has been machine-translated via Google Translate. (fonction membre publique) [edit] | |