Skip to content

Latest commit

 

History

History
70 lines (49 loc) · 1010 Bytes

File metadata and controls

70 lines (49 loc) · 1010 Bytes

operator=

  • atomic[meta header]
  • std[meta namespace]
  • atomic_ref[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
T operator=(T desired) const noexcept;

概要

値を書き込む

効果

以下と等価:

store(desired);
return desired;
  • store[link store.md]

例外

投げない

備考

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

#include <iostream>
#include <atomic>

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

  x = 2;

  std::cout << value << std::endl;
}
  • x = 2;[color ff0000]

出力

2

バージョン

言語

  • C++20

処理系

参照