名前空間
変種
操作

std::deque<T,Allocator>::size

提供: cppreference.com
< cpp‎ | container‎ | deque
 
 
 
 
size_type size()const;
(C++11未満)
size_type size()constnoexcept;
(C++11以上)

コンテナ内の要素の数、すなわち std::distance(begin(), end()) を返します。

目次

[編集]引数

(なし)

[編集]戻り値

コンテナ内の要素の数。

[編集]計算量

一定。

[編集]

以下のコードは size を使用して std::deque 内の要素数を表示します。

#include <deque>#include <iostream>   int main(){std::deque<int> nums {1, 3, 5, 7};   std::cout<<"nums contains "<< nums.size()<<" elements.\n";}

出力:

nums contains 4 elements.

[編集]関連項目

コンテナが空かどうか調べます
(パブリックメンバ関数)[edit]
可能な最大の要素数を返します
(パブリックメンバ関数)[edit]
格納されている要素の数を変更します
(パブリックメンバ関数)[edit]
close