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

履歴 編集

function
<atomic>

std::atomic_ref::operator=(C++20)

T operator=(T desired) const noexcept;

概要

値を書き込む

効果

以下と等価:

store(desired);
return desired;

例外

投げない

備考

  • 参照先の変更ではなく、参照先の値を書き換えるので注意

#include <iostream>
#include <atomic>

int main()
{
  int value = 3;
  std::atomic_ref<int> x{value};

  x = 2;

  std::cout << value << std::endl;
}

出力

2

バージョン

言語

  • C++20

処理系

参照