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

履歴 編集

function
<atomic>

std::atomic::operator=(C++11)

atomic& operator=(const atomic&) = delete;          // (1) C++11
atomic& operator=(const atomic&) volatile = delete; // (2) C++11

T operator=(T desired) volatile noexcept;           // (3) C++11
T operator=(T desired) noexcept;                    // (4) C++11

概要

値を書き込む

テンプレートパラメータ制約

  • (3) :
    • C++20 : atomic<T>::is_always_lock_freetrueであること

効果

store(desired)

戻り値

desired

例外

投げない

#include <iostream>
#include <atomic>

int main()
{
  std::atomic<int> x(1);

  x = 2;

  std::cout << x.load() << std::endl;
}

出力

2

バージョン

言語

  • C++11

処理系

  • Clang: ??
  • GCC: 4.7.0
  • ICC: ??
  • Visual C++: 2012, 2013
    • 2012はコピー代入演算子のdeleteに対応していないため、代わりにprivateで宣言のみ行う手法で代用されている。

関連項目

参照