命名空间
变体
操作

std::atomic_flag_test, std::atomic_flag_test_explicit

来自 cppreference.cn
< cpp‎ | atomic
 
 
并发支持库
线程
(C++11)
(C++20)
this_thread 命名空间
(C++11)
(C++11)
(C++11)
协同取消
互斥
(C++11)
通用锁管理
(C++11)
(C++11)
(C++11)
(C++11)
(C++11)
条件变量
(C++11)
信号量
门闩和屏障
(C++20)
(C++20)
期值
(C++11)
(C++11)
(C++11)
(C++11)
安全回收
(C++26)
危险指针
原子类型
(C++11)
(C++20)
原子类型的初始化
(C++11)(C++20 中已弃用)
(C++11)(C++20 中已弃用)
内存排序
(C++11)(C++26 中已弃用)
原子操作的自由函数
原子标志的自由函数
atomic_flag_testatomic_flag_test_explicit
(C++20)(C++20)
 
定义于头文件 <atomic>
bool atomic_flag_test( const volatile std::atomic_flag* object ) noexcept;
(1) (C++20 起)
bool atomic_flag_test( const std::atomic_flag* object ) noexcept;
(2) (C++20 起)
bool atomic_flag_test_explicit( const volatile std::atomic_flag* object,
                                std::memory_order order ) noexcept;
(3) (C++20 起)
bool atomic_flag_test_explicit( const std::atomic_flag* object,
                                std::memory_order order ) noexcept;
(4) (C++20 起)

原子地读取 *object 的值并返回该值。

1,2) 内存同步顺序为 std::memory_order_seq_cst
3,4) 内存同步顺序为 order
如果 orderstd::memory_order::releasestd::memory_order::acq_rel 之一,则行为未定义。

目录

[编辑] 参数

对象 - 指向要读取的 atomic_flag 对象的指针
顺序 - 内存同步顺序

[编辑] 返回值

原子读取的值。

[编辑] 注意

特性测试 标准 特性
__cpp_lib_atomic_flag_test 201907L (C++20) std::atomic_flag::test

[编辑] 示例

[编辑] 参阅

(C++20)
原子地返回标志的值
(std::atomic_flag 的公共成员函数) [编辑]