std::array::empty
De cppreference.com
![]() | 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. |
constexprbool empty(); | (depuis C++11) | |
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.
You can help to correct and verify the translation. Click here for instructions.
Sommaire |
[modifier]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.
You can help to correct and verify the translation. Click here for instructions.
[modifier]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.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Exceptions
[modifier]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.
You can help to correct and verify the translation. Click here for instructions.
[modifier]Exemple
Le code suivant utilise
empty
pour vérifier si un std::array<int> contient des éléments: Original:
The following code uses
empty
to check if a std::array<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.
You can help to correct and verify the translation. Click here for instructions.
#include <array>#include <iostream> int main(){std::array<int, 4> numbers {3, 1, 4, 1};std::array<int, 0> no_numbers; std::cout<<"numbers.empty(): "<< numbers.empty()<<'\n';std::cout<<"no_numbers.empty(): "<< no_numbers.empty()<<'\n';}
Résultat :
numbers.empty(): 0 no_numbers.empty(): 1
See also
retourne le nombre d'éléments Original: returns the number of elements 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) |