Namespaces
Variants

std::inplace_vector<T,N>:: pop_back

From cppreference.net

constexpr void pop_back ( ) ;

コンテナの最後の要素を削除します。

empty() true の場合:

  • 実装が ハードニング されている場合、 契約違反 が発生します。さらに、"observe"評価セマンティクス下で契約違反ハンドラが戻った場合、動作は未定義です。
  • 実装がハードニングされていない場合、動作は未定義です。

最後の要素へのイテレータと参照は無効化されます。 end() イテレータも同様に無効化されます。

計算量

定数。

#include <inplace_vector>
#include <print>
int main()
{
    std::inplace_vector<int, 4> numbers{1, 2, 3};
    for (; not numbers.empty(); numbers.pop_back())
        std::println("{}", numbers);
}

出力:

[1, 2, 3]
[1, 2]
[1]

関連項目

末尾に要素を追加
(公開メンバ関数)