std::vector::size
提供: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. |
| size_type size() const; |
||
Returns the number of elements in the container, i.e. std::distance(begin(), end()).
目次 |
[編集] パラメータ
(なし)
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.
[編集] 値を返します
コンテナ内の要素の数
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.
[編集] 例外
[編集] 複雑
Constant
[編集] 例
The following code uses size to display the number of elements in a std::vector<int>:
#include <vector> #include <iostream> int main() { std::vector<int> nums {1, 3, 5, 7}; std::cout << "nums contains " << nums.size() << " elements.\n"; }
Output:
nums contains 4 elements.
[編集] も参照してください
| 現在割り当てられているストレージに保持することができる要素の数を返します Original: returns the number of elements that can be held in currently allocated storage The text has been machine-translated via Google Translate. You can help to correct and verify the translation. Click here for instructions. (パブリックメンバ関数) | |
| コンテナが空であるかどうかをチェックします (パブリックメンバ関数) | |
| 要素の最大数を返します 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. (パブリックメンバ関数) | |
| changes the number of elements stored (パブリックメンバ関数) | |