std::deque<T,Allocator>:: pop_back
From ja.cppreference.net
|
void
pop_back
(
)
;
|
(constexpr C++26以降) | |
コンテナの最後の要素を削除します。
|
empty() が true の場合、動作は未定義です。 |
(C++26まで) |
|
empty() が true の場合:
|
(C++26以降) |
最後の要素へのイテレータと参照は無効化されます。
end()
イテレータも同様に無効化されます。
計算量
定数。
例
このコードを実行
#include <deque>
#include <print>
int main()
{
std::deque<int> numbers{1, 2, 3};
for (; not numbers.empty(); numbers.pop_back())
std::println("{}", numbers);
}
出力:
[1, 2, 3]
[1, 2]
[1]
関連項目
|
先頭要素を削除する
(公開メンバ関数) |
|
|
末尾に要素を追加する
(公開メンバ関数) |