std::set::size
De cppreference.com
<metanoindex/>
<tbody> </tbody> size_type size() const; |
||
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
Parâmetros
(Nenhum)
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.
Valor de retorno
o número de elementos no recipiente
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.
Exceções
Complexidade
Constant
Exemplo
The following code uses size to display the number of elements in a std::set<int>:
#include <set>
#include <iostream>
int main()
{
std::set<int> nums {1, 3, 5, 7};
std::cout << "nums contains " << nums.size() << " elements.\n";
}
Saída:
nums contains 4 elements.
