最終更新日時(UTC):
が更新

履歴 編集

function template
<inplace_vector>

std::swap (非メンバ関数)(C++26)

namespace std {
  template <class T, std::size_t N>
  constexpr void swap(inplace_vector<T, N>& x, inplace_vector<T, N>& y)
    noexcept(noexcept(x.swap(y))); // (1) C++26
}

概要

2つのinplace_vectorオブジェクトを入れ替える。

効果

x.swap(y)

戻り値

なし

計算量

x.size()y.size()の大きいほうに対して線形時間

#include <print>
#include <inplace_vector>

int main()
{
  std::inplace_vector<int, 5> v1 = {1, 2, 3};
  std::inplace_vector<int, 5> v2 = {4, 5, 6};

  std::swap(v1, v2);

  for (int x : v1) std::print("{} ", x);
  std::println("");
  for (int x : v2) std::print("{} ", x);
  std::println("");
}

出力

4 5 6
1 2 3

バージョン

言語

  • C++26

処理系

参照