Skip to content

Latest commit

 

History

History
89 lines (64 loc) · 2.09 KB

test.md

File metadata and controls

89 lines (64 loc) · 2.09 KB

test

  • atomic[meta header]
  • std[meta namespace]
  • atomic_flag[meta class]
  • function[meta id-type]
  • cpp20[meta cpp]
bool
  test(memory_order order = memory_order::seq_cst
      ) const volatile noexcept;                  // (1) C++20

bool
  test(memory_order order = memory_order::seq_cst
       ) const noexcept;                          // (2) C++20
constexpr bool
  test(memory_order order = memory_order::seq_cst
       ) const noexcept;                          // (2) C++26
  • memory_order[link /reference/atomic/memory_order.md]

概要

現在の値をbool値として取得する。

要件

orderが以下のメモリオーダーではないこと:

効果

order値によってメモリに影響がある

戻り値

アトミックに読み込まれた*thisが指している値を返す

例外

投げない

#include <iostream>
#include <atomic>

int main()
{
  std::cout << std::boolalpha;

  std::atomic_flag x = ATOMIC_FLAG_INIT;
  std::cout << x.test() << std::endl;

  x.test_and_set();
  std::cout << x.test() << std::endl;
}
  • test()[color ff0000]
  • test_and_set()[link test_and_set.md]
  • ATOMIC_FLAG_INIT[link /reference/atomic/atomic_flag_init.md]

出力

false
true

バージョン

言語

  • C++20

処理系

参照