标准库标头 <stdatomic.h> (C++23)

来自cppreference.com
< cpp‎ | header


 
 
标准库头
通用工具
<any> (C++17)
<bitset>
<bit> (C++20)
<charconv> (C++17)
<expected> (C++23)
<format> (C++20)
<functional>
<optional> (C++17)
<stdbit.h> (C++26)
<tuple> (C++11)
<typeindex> (C++11)
<utility>
<variant> (C++17)
容器
<array> (C++11)
<deque>
<flat_map> (C++23)
<flat_set> (C++23)
<forward_list> (C++11)
<hive> (C++26)
<inplace_vector> (C++26)   
<list>
<map>
<mdspan> (C++23)
<queue>
<set>
<span> (C++20)
<stack>
<unordered_map> (C++11)
<unordered_set> (C++11)
<vector>
迭代器
<iterator>
范围
<generator> (C++23)
<ranges> (C++20)
 

此标头原本在 C 标准库中(<stdatomic.h>)。

此标头是并发支持库的一部分。

未指定 <stdatomic.h> 是否提供任何命名空间 std 中的声明。

目录

(C++23)
使得 _Atomic(T) 等同于 std::atomic<T> 的兼容性宏
(宏函数) [编辑]
初始化 std::atomic_flagfalse
(宏常量) [编辑]

类型

免锁的布尔原子类型
(类) [编辑]
为给定的原子操作定义内存定序约束
(枚举) [编辑]
std::atomic<bool>
(typedef) [编辑]
std::atomic<char>
(typedef) [编辑]
std::atomic<signed char>
(typedef) [编辑]
std::atomic<unsigned char>
(typedef) [编辑]
std::atomic<short>
(typedef) [编辑]
std::atomic<unsigned short>
(typedef) [编辑]
std::atomic<int>
(typedef) [编辑]
std::atomic<unsigned int>
(typedef) [编辑]
std::atomic<long>
(typedef) [编辑]
std::atomic<unsigned long>
(typedef) [编辑]
std::atomic<long long>
(typedef) [编辑]
std::atomic<unsigned long long>
(typedef) [编辑]
std::atomic<char8_t>
(typedef) [编辑]
std::atomic<char16_t>
(typedef) [编辑]
std::atomic<char32_t>
(typedef) [编辑]
std::atomic<wchar_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::int8_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::uint8_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::int16_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::uint16_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::int32_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::uint32_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::int64_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::uint64_t>
(typedef) [编辑]
std::atomic<std::int_least8_t>
(typedef) [编辑]
std::atomic<std::uint_least8_t>
(typedef) [编辑]
std::atomic<std::int_least16_t>
(typedef) [编辑]
std::atomic<std::uint_least16_t>
(typedef) [编辑]
std::atomic<std::int_least32_t>
(typedef) [编辑]
std::atomic<std::uint_least32_t>
(typedef) [编辑]
std::atomic<std::int_least64_t>
(typedef) [编辑]
std::atomic<std::uint_least64_t>
(typedef) [编辑]
std::atomic<std::int_fast8_t>
(typedef) [编辑]
std::atomic<std::uint_fast8_t>
(typedef) [编辑]
std::atomic<std::int_fast16_t>
(typedef) [编辑]
std::atomic<std::uint_fast16_t>
(typedef) [编辑]
std::atomic<std::int_fast32_t>
(typedef) [编辑]
std::atomic<std::uint_fast32_t>
(typedef) [编辑]
std::atomic<std::int_fast64_t>
(typedef) [编辑]
std::atomic<std::uint_fast64_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::intptr_t>
(typedef) [编辑]
(C++11)(可选)
std::atomic<std::uintptr_t>
(typedef) [编辑]
std::atomic<std::size_t>
(typedef) [编辑]
std::atomic<std::ptrdiff_t>
(typedef) [编辑]
std::atomic<std::intmax_t>
(typedef) [编辑]
std::atomic<std::uintmax_t>
(typedef) [编辑]

函数

检查该原子类型的操作是否是免锁的
(函数模板) [编辑]
原子地以非原子实参替换原子对象的值
(函数模板) [编辑]
原子地获得存储于原子对象的值
(函数模板) [编辑]
原子地以非原子实参的值替换原子对象的值,并返回该原子对象的旧值
(函数模板) [编辑]
原子地比较原子对象和非原子实参的值,相等时进行原子交换,不相等时进行原子加载
(函数模板) [编辑]
将非原子值加到原子对象上,并获得原子对象的先前值
(函数模板) [编辑]
从原子对象中减去非原子值,并获得原子对象的先前值
(函数模板) [编辑]
将原子对象替换为与非原子实参逐位与的结果,并获得原子对象的先前值
(函数模板) [编辑]
将原子对象替换为与非原子实参逐位或的结果,并获得原子对象的先前值
(函数模板) [编辑]
将原子对象替换为与非原子实参逐位异或的结果,并获得原子对象的先前值
(函数模板) [编辑]
原子地设置标志为 true 并返回其先前值
(函数) [编辑]
原子地设置标志值为 false
(函数) [编辑]
通用的依赖内存定序的栅栏同步原语
(函数) [编辑]
线程与执行于同一线程的信号处理函数间的栅栏
(函数) [编辑]

[编辑] 概要

template<class T>
  using __std_atomic = std::atomic<T>;        // 仅用于阐释
 
#define _Atomic(T) __std_atomic<T>
 
#define ATOMIC_BOOL_LOCK_FREE /* 见描述 */
#define ATOMIC_CHAR_LOCK_FREE /* 见描述 */
#define ATOMIC_CHAR16_T_LOCK_FREE /* 见描述 */
#define ATOMIC_CHAR32_T_LOCK_FREE /* 见描述 */
#define ATOMIC_WCHAR_T_LOCK_FREE /* 见描述 */
#define ATOMIC_SHORT_LOCK_FREE /* 见描述 */
#define ATOMIC_INT_LOCK_FREE /* 见描述 */
#define ATOMIC_LONG_LOCK_FREE /* 见描述 */
#define ATOMIC_LLONG_LOCK_FREE /* 见描述 */
#define ATOMIC_POINTER_LOCK_FREE /* 见描述 */
 
using std::memory_order;                // 见描述
using std::memory_order_relaxed;        // 见描述
using std::memory_order_consume;        // 见描述
using std::memory_order_acquire;        // 见描述
using std::memory_order_release;        // 见描述
using std::memory_order_acq_rel;        // 见描述
using std::memory_order_seq_cst;        // 见描述
 
using std::atomic_flag;                 // 见描述
 
using std::atomic_bool;                 // 见描述
using std::atomic_char;                 // 见描述
using std::atomic_schar;                // 见描述
using std::atomic_uchar;                // 见描述
using std::atomic_short;                // 见描述
using std::atomic_ushort;               // 见描述
using std::atomic_int;                  // 见描述
using std::atomic_uint;                 // 见描述
using std::atomic_long;                 // 见描述
using std::atomic_ulong;                // 见描述
using std::atomic_llong;                // 见描述
using std::atomic_ullong;               // 见描述
using std::atomic_char8_t;              // 见描述
using std::atomic_char16_t;             // 见描述
using std::atomic_char32_t;             // 见描述
using std::atomic_wchar_t;              // 见描述
using std::atomic_int8_t;               // 见描述
using std::atomic_uint8_t;              // 见描述
using std::atomic_int16_t;              // 见描述
using std::atomic_uint16_t;             // 见描述
using std::atomic_int32_t;              // 见描述
using std::atomic_uint32_t;             // 见描述
using std::atomic_int64_t;              // 见描述
using std::atomic_uint64_t;             // 见描述
using std::atomic_int_least8_t;         // 见描述
using std::atomic_uint_least8_t;        // 见描述
using std::atomic_int_least16_t;        // 见描述
using std::atomic_uint_least16_t;       // 见描述
using std::atomic_int_least32_t;        // 见描述
using std::atomic_uint_least32_t;       // 见描述
using std::atomic_int_least64_t;        // 见描述
using std::atomic_uint_least64_t;       // 见描述
using std::atomic_int_fast8_t;          // 见描述
using std::atomic_uint_fast8_t;         // 见描述
using std::atomic_int_fast16_t;         // 见描述
using std::atomic_uint_fast16_t;        // 见描述
using std::atomic_int_fast32_t;         // 见描述
using std::atomic_uint_fast32_t;        // 见描述
using std::atomic_int_fast64_t;         // 见描述
using std::atomic_uint_fast64_t;        // 见描述
using std::atomic_intptr_t;             // 见描述
using std::atomic_uintptr_t;            // 见描述
using std::atomic_size_t;               // 见描述
using std::atomic_ptrdiff_t;            // 见描述
using std::atomic_intmax_t;             // 见描述
using std::atomic_uintmax_t;            // 见描述
 
using std::atomic_is_lock_free;                         // 见描述
using std::atomic_load;                                 // 见描述
using std::atomic_load_explicit;                        // 见描述
using std::atomic_store;                                // 见描述
using std::atomic_store_explicit;                       // 见描述
using std::atomic_exchange;                             // 见描述
using std::atomic_exchange_explicit;                    // 见描述
using std::atomic_compare_exchange_strong;              // 见描述
using std::atomic_compare_exchange_strong_explicit;     // 见描述
using std::atomic_compare_exchange_weak;                // 见描述
using std::atomic_compare_exchange_weak_explicit;       // 见描述
using std::atomic_fetch_add;                            // 见描述
using std::atomic_fetch_add_explicit;                   // 见描述
using std::atomic_fetch_sub;                            // 见描述
using std::atomic_fetch_sub_explicit;                   // 见描述
using std::atomic_fetch_or;                             // 见描述
using std::atomic_fetch_or_explicit;                    // 见描述
using std::atomic_fetch_xor;                            // 见描述
using std::atomic_fetch_xor_explicit;                   // 见描述
using std::atomic_fetch_and;                            // 见描述
using std::atomic_fetch_and_explicit;                   // 见描述
using std::atomic_flag_test_and_set;                    // 见描述
using std::atomic_flag_test_and_set_explicit;           // 见描述
using std::atomic_flag_clear;                           // 见描述
using std::atomic_flag_clear_explicit;                  // 见描述
 
#define ATOMIC_FLAG_INIT /* 见描述 */
 
using std::atomic_thread_fence;                         // 见描述
using std::atomic_signal_fence;                         // 见描述