std::array::size
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. |
constexpr size_type size() | (depuis C++11) | |
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
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
le nombre d'éléments dans le conteneur
Original:
the number of elements in the container
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é
Constant
[modifier]Exemple
The following code uses size
to display the number of elements in a std::array<int>:
#include <array>#include <iostream> int main(){std::array<int> nums {1, 3, 5, 7}; std::cout<<"nums contains "<< nums.size()<<" elements.\n";}
Résultat :
nums contains 4 elements.
[modifier]Voir aussi
vérifie si le conteneur est vide Original: checks whether the container is empty 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) | |
retourne le plus grand nombre possible d'éléments Original: returns the maximum possible 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) |