最終更新日時:
が更新

履歴 編集

function template
<hive>

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

namespace std {
  template <class T, class Allocator>
  void swap(hive<T, Allocator>& x,
            hive<T, Allocator>& y) noexcept(noexcept(x.swap(y))); // (1) C++26
}

概要

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

効果

x.swap(y)と等価である。

戻り値

なし

#include <hive>
#include <print>

void print(const char* name, const std::hive<int>& h)
{
  std::print("{} : ", name);
  for (int x : h) {
    std::print("{} ", x);
  }
  std::println("");
}

int main()
{
  std::hive<int> h1 = {1, 2, 3};
  std::hive<int> h2 = {4, 5, 6};

  std::swap(h1, h2);

  print("h1", h1);
  print("h2", h2);
}

出力

h1 : 4 5 6 
h2 : 1 2 3 

バージョン

言語

  • C++26

処理系

関連項目

参照