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

履歴 編集

function
<atomic>

std::atomic::fetch_fmaximum_num(C++26)

constexpr T
  fetch_fmaximum_num(difference_type operand,
                     memory_order order = memory_order_seq_cst
                     ) noexcept;                               // (1) C++26

概要

最大値を設定・取得する。

この関数は、*thisが保持する値とoperandの大きい方を求め、その値をthisに保持させた上でその値を返す。

効果

orderで指定されたメモリオーダーにしたがって、*thisが保持する値とoperandの最大値を求めて、その値をthisに保持させ、その値を返す

例外

投げない

備考

  • この関数は、atomicクラスの浮動小数点数型に対する特殊化で定義される
  • 浮動小数点数型

#include <iostream>
#include <atomic>

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

  int ret = x.fetch_fmaximum_num(3);

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

出力

3
3

バージョン

言語

  • C++26

処理系

参照