libstdc++
atomic
Go to the documentation of this file.
1// -*- C++ -*- header.
2
3// Copyright (C) 2008-2026 Free Software Foundation, Inc.
4//
5// This file is part of the GNU ISO C++ Library. This library is free
6// software; you can redistribute it and/or modify it under the
7// terms of the GNU General Public License as published by the
8// Free Software Foundation; either version 3, or (at your option)
9// any later version.
10
11// This library is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// Under Section 7 of GPL version 3, you are granted additional
17// permissions described in the GCC Runtime Library Exception, version
18// 3.1, as published by the Free Software Foundation.
19
20// You should have received a copy of the GNU General Public License and
21// a copy of the GCC Runtime Library Exception along with this program;
22// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23// <http://www.gnu.org/licenses/>.
24
25/** @file include/atomic
26 * This is a Standard C++ Library header.
27 */
28
29// Based on "C++ Atomic Types and Operations" by Hans Boehm and Lawrence Crowl.
30// http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2427.html
31
32#ifndef _GLIBCXX_ATOMIC
33#define _GLIBCXX_ATOMIC 1
34
35#ifdef _GLIBCXX_SYSHDR
36#pragma GCC system_header
37#endif
38
39#if __cplusplus < 201103L
40# include <bits/c++0x_warning.h>
41#else
42
43#define __glibcxx_want_atomic_is_always_lock_free
44#define __glibcxx_want_atomic_flag_test
45#define __glibcxx_want_atomic_float
46#define __glibcxx_want_atomic_min_max
47#define __glibcxx_want_atomic_ref
48#define __glibcxx_want_atomic_lock_free_type_aliases
49#define __glibcxx_want_atomic_value_initialization
50#define __glibcxx_want_atomic_wait
51#include <bits/version.h>
52
53#include <bits/atomic_base.h>
54#include <cstdint>
55#include <type_traits>
56
57namespace std _GLIBCXX_VISIBILITY(default)
58{
59_GLIBCXX_BEGIN_NAMESPACE_VERSION
60
61 /**
62 * @addtogroup atomics
63 * @{
64 */
65
66 template<typename _Tp>
67 struct atomic;
68
69 /// atomic<bool>
70 // NB: No operators or fetch-operations for this type.
71 template<>
72 struct atomic<bool>
73 {
74 using value_type = bool;
75
76 private:
77 __atomic_base<bool> _M_base;
78
79 public:
80 atomic() noexcept = default;
81 ~atomic() noexcept = default;
82 atomic(const atomic&) = delete;
83 atomic& operator=(const atomic&) = delete;
84 atomic& operator=(const atomic&) volatile = delete;
85
86 constexpr atomic(bool __i) noexcept : _M_base(__i) { }
87
88 bool
89 operator=(bool __i) noexcept
90 { return _M_base.operator=(__i); }
91
92 bool
93 operator=(bool __i) volatile noexcept
94 { return _M_base.operator=(__i); }
95
96 operator bool() const noexcept
97 { return _M_base.load(); }
98
99 operator bool() const volatile noexcept
100 { return _M_base.load(); }
101
102 bool
103 is_lock_free() const noexcept { return _M_base.is_lock_free(); }
104
105 bool
106 is_lock_free() const volatile noexcept { return _M_base.is_lock_free(); }
107
108#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
109 static constexpr bool is_always_lock_free = ATOMIC_BOOL_LOCK_FREE == 2;
110#endif
111
112 _GLIBCXX_ALWAYS_INLINE
113 void
114 store(bool __i, memory_order __m = memory_order_seq_cst) noexcept
115 { _M_base.store(__i, __m); }
116
117 _GLIBCXX_ALWAYS_INLINE
118 void
119 store(bool __i, memory_order __m = memory_order_seq_cst) volatile noexcept
120 { _M_base.store(__i, __m); }
121
122 _GLIBCXX_ALWAYS_INLINE
123 bool
124 load(memory_order __m = memory_order_seq_cst) const noexcept
125 { return _M_base.load(__m); }
126
127 _GLIBCXX_ALWAYS_INLINE
128 bool
129 load(memory_order __m = memory_order_seq_cst) const volatile noexcept
130 { return _M_base.load(__m); }
131
132 _GLIBCXX_ALWAYS_INLINE
133 bool
134 exchange(bool __i, memory_order __m = memory_order_seq_cst) noexcept
135 { return _M_base.exchange(__i, __m); }
136
137 _GLIBCXX_ALWAYS_INLINE
138 bool
139 exchange(bool __i,
140 memory_order __m = memory_order_seq_cst) volatile noexcept
141 { return _M_base.exchange(__i, __m); }
142
143 _GLIBCXX_ALWAYS_INLINE
144 bool
145 compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
146 memory_order __m2) noexcept
147 { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
148
149 _GLIBCXX_ALWAYS_INLINE
150 bool
151 compare_exchange_weak(bool& __i1, bool __i2, memory_order __m1,
152 memory_order __m2) volatile noexcept
153 { return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
154
155 _GLIBCXX_ALWAYS_INLINE
156 bool
157 compare_exchange_weak(bool& __i1, bool __i2,
158 memory_order __m = memory_order_seq_cst) noexcept
159 { return _M_base.compare_exchange_weak(__i1, __i2, __m); }
160
161 _GLIBCXX_ALWAYS_INLINE
162 bool
163 compare_exchange_weak(bool& __i1, bool __i2,
164 memory_order __m = memory_order_seq_cst) volatile noexcept
165 { return _M_base.compare_exchange_weak(__i1, __i2, __m); }
166
167 _GLIBCXX_ALWAYS_INLINE
168 bool
169 compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
170 memory_order __m2) noexcept
171 { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
172
173 _GLIBCXX_ALWAYS_INLINE
174 bool
175 compare_exchange_strong(bool& __i1, bool __i2, memory_order __m1,
176 memory_order __m2) volatile noexcept
177 { return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
178
179 _GLIBCXX_ALWAYS_INLINE
180 bool
181 compare_exchange_strong(bool& __i1, bool __i2,
182 memory_order __m = memory_order_seq_cst) noexcept
183 { return _M_base.compare_exchange_strong(__i1, __i2, __m); }
184
185 _GLIBCXX_ALWAYS_INLINE
186 bool
187 compare_exchange_strong(bool& __i1, bool __i2,
188 memory_order __m = memory_order_seq_cst) volatile noexcept
189 { return _M_base.compare_exchange_strong(__i1, __i2, __m); }
190
191#if __cpp_lib_atomic_wait
192 _GLIBCXX_ALWAYS_INLINE
193 void
194 wait(bool __old, memory_order __m = memory_order_seq_cst) const noexcept
195 { _M_base.wait(__old, __m); }
196
197 // TODO add const volatile overload
198
199 void
200 notify_one() noexcept
201 { _M_base.notify_one(); }
202
203 void
204 notify_all() noexcept
205 { _M_base.notify_all(); }
206#endif // __cpp_lib_atomic_wait
207 };
208
209 /**
210 * @brief Generic atomic type, primary class template.
211 *
212 * @tparam _Tp Type to be made atomic, must be trivially copyable.
213 */
214 template<typename _Tp>
215 struct atomic
216 {
217 using value_type = _Tp;
218
219 private:
220 // Align 1/2/4/8/16-byte types to at least their size.
221 static constexpr int _S_min_alignment
222 = (sizeof(_Tp) & (sizeof(_Tp) - 1)) || sizeof(_Tp) > 16
223 ? 0 : sizeof(_Tp);
224
225 static constexpr int _S_alignment
226 = _S_min_alignment > alignof(_Tp) ? _S_min_alignment : alignof(_Tp);
227
228 alignas(_S_alignment) _Tp _M_i;
229
230 static_assert(__is_trivially_copyable(_Tp),
231 "std::atomic requires a trivially copyable type");
232
233 static_assert(sizeof(_Tp) > 0,
234 "Incomplete or zero-sized types are not supported");
235
236 // _GLIBCXX_RESOLVE_LIB_DEFECTS
237 // 4069. std::atomic<volatile T> should be ill-formed
238 static_assert(is_same<_Tp, typename remove_cv<_Tp>::type>::value,
239 "template argument for std::atomic must not be const or volatile");
240
241#if __cplusplus > 201703L
242 static_assert(is_copy_constructible_v<_Tp>);
243 static_assert(is_move_constructible_v<_Tp>);
244 static_assert(is_copy_assignable_v<_Tp>);
245 static_assert(is_move_assignable_v<_Tp>);
246#endif
247
248 public:
249#if __cpp_lib_atomic_value_initialization
250 // _GLIBCXX_RESOLVE_LIB_DEFECTS
251 // 4169. std::atomic<T>'s default constructor should be constrained
252 constexpr atomic() noexcept(is_nothrow_default_constructible_v<_Tp>)
253 requires is_default_constructible_v<_Tp>
254 : _M_i()
255 {}
256#else
257 atomic() = default;
258#endif
259
260 ~atomic() noexcept = default;
261 atomic(const atomic&) = delete;
262 atomic& operator=(const atomic&) = delete;
263 atomic& operator=(const atomic&) volatile = delete;
264
265#pragma GCC diagnostic push
266#pragma GCC diagnostic ignored "-Wc++14-extensions" // constexpr ctor body
267 constexpr atomic(_Tp __i) noexcept : _M_i(__i)
268 {
269#if __has_builtin(__builtin_clear_padding)
270 if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>())
271 if (!std::__is_constant_evaluated())
272 __builtin_clear_padding(std::__addressof(_M_i));
273#endif
274 }
275#pragma GCC diagnostic pop
276
277 operator _Tp() const noexcept
278 { return load(); }
279
280 operator _Tp() const volatile noexcept
281 { return load(); }
282
283 _Tp
284 operator=(_Tp __i) noexcept
285 { store(__i); return __i; }
286
287 _Tp
288 operator=(_Tp __i) volatile noexcept
289 { store(__i); return __i; }
290
291 bool
292 is_lock_free() const noexcept
293 {
294 // Produce a fake, minimally aligned pointer.
295 return __atomic_is_lock_free(sizeof(_M_i),
296 reinterpret_cast<void *>(-_S_alignment));
297 }
298
299 bool
300 is_lock_free() const volatile noexcept
301 {
302 // Produce a fake, minimally aligned pointer.
303 return __atomic_is_lock_free(sizeof(_M_i),
304 reinterpret_cast<void *>(-_S_alignment));
305 }
306
307#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
308 static constexpr bool is_always_lock_free
309 = __atomic_always_lock_free(sizeof(_M_i), 0);
310#endif
311
312 _GLIBCXX_ALWAYS_INLINE
313 void
314 store(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept
315 {
316 __atomic_store(std::__addressof(_M_i),
317 __atomic_impl::__clear_padding(__i),
318 int(__m));
319 }
320
321 _GLIBCXX_ALWAYS_INLINE
322 void
323 store(_Tp __i, memory_order __m = memory_order_seq_cst) volatile noexcept
324 {
325 __atomic_store(std::__addressof(_M_i),
326 __atomic_impl::__clear_padding(__i),
327 int(__m));
328 }
329
330 _GLIBCXX_ALWAYS_INLINE
331 _Tp
332 load(memory_order __m = memory_order_seq_cst) const noexcept
333 {
334 alignas(_Tp) unsigned char __buf[sizeof(_Tp)];
335 _Tp* __ptr = reinterpret_cast<_Tp*>(__buf);
336 __atomic_load(std::__addressof(_M_i), __ptr, int(__m));
337 return *__ptr;
338 }
339
340 _GLIBCXX_ALWAYS_INLINE
341 _Tp
342 load(memory_order __m = memory_order_seq_cst) const volatile noexcept
343 {
344 alignas(_Tp) unsigned char __buf[sizeof(_Tp)];
345 _Tp* __ptr = reinterpret_cast<_Tp*>(__buf);
346 __atomic_load(std::__addressof(_M_i), __ptr, int(__m));
347 return *__ptr;
348 }
349
350 _GLIBCXX_ALWAYS_INLINE
351 _Tp
352 exchange(_Tp __i, memory_order __m = memory_order_seq_cst) noexcept
353 {
354 alignas(_Tp) unsigned char __buf[sizeof(_Tp)];
355 _Tp* __ptr = reinterpret_cast<_Tp*>(__buf);
356 __atomic_exchange(std::__addressof(_M_i),
357 __atomic_impl::__clear_padding(__i),
358 __ptr, int(__m));
359 return *__ptr;
360 }
361
362 _GLIBCXX_ALWAYS_INLINE
363 _Tp
364 exchange(_Tp __i,
365 memory_order __m = memory_order_seq_cst) volatile noexcept
366 {
367 alignas(_Tp) unsigned char __buf[sizeof(_Tp)];
368 _Tp* __ptr = reinterpret_cast<_Tp*>(__buf);
369 __atomic_exchange(std::__addressof(_M_i),
370 __atomic_impl::__clear_padding(__i),
371 __ptr, int(__m));
372 return *__ptr;
373 }
374
375 _GLIBCXX_ALWAYS_INLINE
376 bool
377 compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s,
378 memory_order __f) noexcept
379 {
380 return __atomic_impl::__compare_exchange(_M_i, __e, __i, true,
381 __s, __f);
382 }
383
384 _GLIBCXX_ALWAYS_INLINE
385 bool
386 compare_exchange_weak(_Tp& __e, _Tp __i, memory_order __s,
387 memory_order __f) volatile noexcept
388 {
389 return __atomic_impl::__compare_exchange(_M_i, __e, __i, true,
390 __s, __f);
391 }
392
393 _GLIBCXX_ALWAYS_INLINE
394 bool
395 compare_exchange_weak(_Tp& __e, _Tp __i,
396 memory_order __m = memory_order_seq_cst) noexcept
397 { return compare_exchange_weak(__e, __i, __m,
398 __cmpexch_failure_order(__m)); }
399
400 _GLIBCXX_ALWAYS_INLINE
401 bool
402 compare_exchange_weak(_Tp& __e, _Tp __i,
403 memory_order __m = memory_order_seq_cst) volatile noexcept
404 { return compare_exchange_weak(__e, __i, __m,
405 __cmpexch_failure_order(__m)); }
406
407 _GLIBCXX_ALWAYS_INLINE
408 bool
409 compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s,
410 memory_order __f) noexcept
411 {
412 return __atomic_impl::__compare_exchange(_M_i, __e, __i, false,
413 __s, __f);
414 }
415
416 _GLIBCXX_ALWAYS_INLINE
417 bool
418 compare_exchange_strong(_Tp& __e, _Tp __i, memory_order __s,
419 memory_order __f) volatile noexcept
420 {
421 return __atomic_impl::__compare_exchange(_M_i, __e, __i, false,
422 __s, __f);
423 }
424
425 _GLIBCXX_ALWAYS_INLINE
426 bool
427 compare_exchange_strong(_Tp& __e, _Tp __i,
428 memory_order __m = memory_order_seq_cst) noexcept
429 { return compare_exchange_strong(__e, __i, __m,
430 __cmpexch_failure_order(__m)); }
431
432 _GLIBCXX_ALWAYS_INLINE
433 bool
434 compare_exchange_strong(_Tp& __e, _Tp __i,
435 memory_order __m = memory_order_seq_cst) volatile noexcept
436 { return compare_exchange_strong(__e, __i, __m,
437 __cmpexch_failure_order(__m)); }
438
439#if __cpp_lib_atomic_wait // C++ >= 20
440 _GLIBCXX_ALWAYS_INLINE
441 void
442 wait(_Tp __old, memory_order __m = memory_order_seq_cst) const noexcept
443 {
444 std::__atomic_wait_address_v(std::addressof(_M_i), __old,
445 [__m, this] { return this->load(__m); });
446 }
447
448 // TODO add const volatile overload
449
450 void
451 notify_one() noexcept
452 { std::__atomic_notify_address(std::addressof(_M_i), false); }
453
454 void
455 notify_all() noexcept
456 { std::__atomic_notify_address(std::addressof(_M_i), true); }
457#endif // __cpp_lib_atomic_wait
458 };
459
460 /// Partial specialization for pointer types.
461 template<typename _Tp>
462 struct atomic<_Tp*>
463 {
464 using value_type = _Tp*;
465 using difference_type = ptrdiff_t;
466
467 typedef _Tp* __pointer_type;
468 typedef __atomic_base<_Tp*> __base_type;
469 __base_type _M_b;
470
471 atomic() noexcept = default;
472 ~atomic() noexcept = default;
473 atomic(const atomic&) = delete;
474 atomic& operator=(const atomic&) = delete;
475 atomic& operator=(const atomic&) volatile = delete;
476
477 constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { }
478
479 operator __pointer_type() const noexcept
480 { return __pointer_type(_M_b); }
481
482 operator __pointer_type() const volatile noexcept
483 { return __pointer_type(_M_b); }
484
485 __pointer_type
486 operator=(__pointer_type __p) noexcept
487 { return _M_b.operator=(__p); }
488
489 __pointer_type
490 operator=(__pointer_type __p) volatile noexcept
491 { return _M_b.operator=(__p); }
492
493 __pointer_type
494 operator++(int) noexcept
495 {
496#if __cplusplus >= 201703L
497 static_assert( is_object_v<_Tp>, "pointer to object type" );
498#endif
499 return _M_b++;
500 }
501
502 __pointer_type
503 operator++(int) volatile noexcept
504 {
505#if __cplusplus >= 201703L
506 static_assert( is_object_v<_Tp>, "pointer to object type" );
507#endif
508 return _M_b++;
509 }
510
511 __pointer_type
512 operator--(int) noexcept
513 {
514#if __cplusplus >= 201703L
515 static_assert( is_object_v<_Tp>, "pointer to object type" );
516#endif
517 return _M_b--;
518 }
519
520 __pointer_type
521 operator--(int) volatile noexcept
522 {
523#if __cplusplus >= 201703L
524 static_assert( is_object_v<_Tp>, "pointer to object type" );
525#endif
526 return _M_b--;
527 }
528
529 __pointer_type
530 operator++() noexcept
531 {
532#if __cplusplus >= 201703L
533 static_assert( is_object_v<_Tp>, "pointer to object type" );
534#endif
535 return ++_M_b;
536 }
537
538 __pointer_type
539 operator++() volatile noexcept
540 {
541#if __cplusplus >= 201703L
542 static_assert( is_object_v<_Tp>, "pointer to object type" );
543#endif
544 return ++_M_b;
545 }
546
547 __pointer_type
548 operator--() noexcept
549 {
550#if __cplusplus >= 201703L
551 static_assert( is_object_v<_Tp>, "pointer to object type" );
552#endif
553 return --_M_b;
554 }
555
556 __pointer_type
557 operator--() volatile noexcept
558 {
559#if __cplusplus >= 201703L
560 static_assert( is_object_v<_Tp>, "pointer to object type" );
561#endif
562 return --_M_b;
563 }
564
565 __pointer_type
566 operator+=(ptrdiff_t __d) noexcept
567 {
568#if __cplusplus >= 201703L
569 static_assert( is_object_v<_Tp>, "pointer to object type" );
570#endif
571 return _M_b.operator+=(__d);
572 }
573
574 __pointer_type
575 operator+=(ptrdiff_t __d) volatile noexcept
576 {
577#if __cplusplus >= 201703L
578 static_assert( is_object_v<_Tp>, "pointer to object type" );
579#endif
580 return _M_b.operator+=(__d);
581 }
582
583 __pointer_type
584 operator-=(ptrdiff_t __d) noexcept
585 {
586#if __cplusplus >= 201703L
587 static_assert( is_object_v<_Tp>, "pointer to object type" );
588#endif
589 return _M_b.operator-=(__d);
590 }
591
592 __pointer_type
593 operator-=(ptrdiff_t __d) volatile noexcept
594 {
595#if __cplusplus >= 201703L
596 static_assert( is_object_v<_Tp>, "pointer to object type" );
597#endif
598 return _M_b.operator-=(__d);
599 }
600
601 bool
602 is_lock_free() const noexcept
603 { return _M_b.is_lock_free(); }
604
605 bool
606 is_lock_free() const volatile noexcept
607 { return _M_b.is_lock_free(); }
608
609#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
610 static constexpr bool is_always_lock_free
611 = ATOMIC_POINTER_LOCK_FREE == 2;
612#endif
613
614 _GLIBCXX_ALWAYS_INLINE
615 void
616 store(__pointer_type __p,
617 memory_order __m = memory_order_seq_cst) noexcept
618 { return _M_b.store(__p, __m); }
619
620 _GLIBCXX_ALWAYS_INLINE
621 void
622 store(__pointer_type __p,
623 memory_order __m = memory_order_seq_cst) volatile noexcept
624 { return _M_b.store(__p, __m); }
625
626 _GLIBCXX_ALWAYS_INLINE
627 __pointer_type
628 load(memory_order __m = memory_order_seq_cst) const noexcept
629 { return _M_b.load(__m); }
630
631 _GLIBCXX_ALWAYS_INLINE
632 __pointer_type
633 load(memory_order __m = memory_order_seq_cst) const volatile noexcept
634 { return _M_b.load(__m); }
635
636 _GLIBCXX_ALWAYS_INLINE
637 __pointer_type
638 exchange(__pointer_type __p,
639 memory_order __m = memory_order_seq_cst) noexcept
640 { return _M_b.exchange(__p, __m); }
641
642 _GLIBCXX_ALWAYS_INLINE
643 __pointer_type
644 exchange(__pointer_type __p,
645 memory_order __m = memory_order_seq_cst) volatile noexcept
646 { return _M_b.exchange(__p, __m); }
647
648 _GLIBCXX_ALWAYS_INLINE
649 bool
650 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
651 memory_order __m1, memory_order __m2) noexcept
652 { return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
653
654 _GLIBCXX_ALWAYS_INLINE
655 bool
656 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
657 memory_order __m1,
658 memory_order __m2) volatile noexcept
659 { return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
660
661 _GLIBCXX_ALWAYS_INLINE
662 bool
663 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
664 memory_order __m = memory_order_seq_cst) noexcept
665 {
666 return compare_exchange_weak(__p1, __p2, __m,
667 __cmpexch_failure_order(__m));
668 }
669
670 _GLIBCXX_ALWAYS_INLINE
671 bool
672 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
673 memory_order __m = memory_order_seq_cst) volatile noexcept
674 {
675 return compare_exchange_weak(__p1, __p2, __m,
676 __cmpexch_failure_order(__m));
677 }
678
679 _GLIBCXX_ALWAYS_INLINE
680 bool
681 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
682 memory_order __m1, memory_order __m2) noexcept
683 { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
684
685 _GLIBCXX_ALWAYS_INLINE
686 bool
687 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
688 memory_order __m1,
689 memory_order __m2) volatile noexcept
690 { return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
691
692 _GLIBCXX_ALWAYS_INLINE
693 bool
694 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
695 memory_order __m = memory_order_seq_cst) noexcept
696 {
697 return _M_b.compare_exchange_strong(__p1, __p2, __m,
698 __cmpexch_failure_order(__m));
699 }
700
701 _GLIBCXX_ALWAYS_INLINE
702 bool
703 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
704 memory_order __m = memory_order_seq_cst) volatile noexcept
705 {
706 return _M_b.compare_exchange_strong(__p1, __p2, __m,
707 __cmpexch_failure_order(__m));
708 }
709
710#if __cpp_lib_atomic_wait
711 _GLIBCXX_ALWAYS_INLINE
712 void
713 wait(__pointer_type __old,
714 memory_order __m = memory_order_seq_cst) const noexcept
715 { _M_b.wait(__old, __m); }
716
717 // TODO add const volatile overload
718
719 void
720 notify_one() noexcept
721 { _M_b.notify_one(); }
722
723 void
724 notify_all() noexcept
725 { _M_b.notify_all(); }
726#endif // __cpp_lib_atomic_wait
727
728 _GLIBCXX_ALWAYS_INLINE
729 __pointer_type
730 fetch_add(ptrdiff_t __d,
731 memory_order __m = memory_order_seq_cst) noexcept
732 {
733#if __cplusplus >= 201703L
734 static_assert( is_object_v<_Tp>, "pointer to object type" );
735#endif
736 return _M_b.fetch_add(__d, __m);
737 }
738
739 _GLIBCXX_ALWAYS_INLINE
740 __pointer_type
741 fetch_add(ptrdiff_t __d,
742 memory_order __m = memory_order_seq_cst) volatile noexcept
743 {
744#if __cplusplus >= 201703L
745 static_assert( is_object_v<_Tp>, "pointer to object type" );
746#endif
747 return _M_b.fetch_add(__d, __m);
748 }
749
750 _GLIBCXX_ALWAYS_INLINE
751 __pointer_type
752 fetch_sub(ptrdiff_t __d,
753 memory_order __m = memory_order_seq_cst) noexcept
754 {
755#if __cplusplus >= 201703L
756 static_assert( is_object_v<_Tp>, "pointer to object type" );
757#endif
758 return _M_b.fetch_sub(__d, __m);
759 }
760
761 _GLIBCXX_ALWAYS_INLINE
762 __pointer_type
763 fetch_sub(ptrdiff_t __d,
764 memory_order __m = memory_order_seq_cst) volatile noexcept
765 {
766#if __cplusplus >= 201703L
767 static_assert( is_object_v<_Tp>, "pointer to object type" );
768#endif
769 return _M_b.fetch_sub(__d, __m);
770 }
771
772#if __glibcxx_atomic_min_max
773 _GLIBCXX_ALWAYS_INLINE
774 __pointer_type
775 fetch_min(__pointer_type __p,
776 memory_order __m = memory_order_seq_cst) noexcept
777 { return _M_b.fetch_min(__p, __m); }
778
779 _GLIBCXX_ALWAYS_INLINE
780 __pointer_type
781 fetch_min(__pointer_type __p,
782 memory_order __m = memory_order_seq_cst) volatile noexcept
783 { return _M_b.fetch_min(__p, __m); }
784
785 _GLIBCXX_ALWAYS_INLINE
786 __pointer_type
787 fetch_max(__pointer_type __p,
788 memory_order __m = memory_order_seq_cst) noexcept
789 { return _M_b.fetch_max(__p, __m); }
790
791 _GLIBCXX_ALWAYS_INLINE
792 __pointer_type
793 fetch_max(__pointer_type __p,
794 memory_order __m = memory_order_seq_cst) volatile noexcept
795 { return _M_b.fetch_max(__p, __m); }
796#endif
797 };
798
799
800 /// Explicit specialization for char.
801 template<>
802 struct atomic<char> : __atomic_base<char>
803 {
804 typedef char __integral_type;
805 typedef __atomic_base<char> __base_type;
806
807 atomic() noexcept = default;
808 ~atomic() noexcept = default;
809 atomic(const atomic&) = delete;
810 atomic& operator=(const atomic&) = delete;
811 atomic& operator=(const atomic&) volatile = delete;
812
813 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
814
815 using __base_type::operator __integral_type;
816 using __base_type::operator=;
817
818#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
819 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
820#endif
821 };
822
823 /// Explicit specialization for signed char.
824 template<>
825 struct atomic<signed char> : __atomic_base<signed char>
826 {
827 typedef signed char __integral_type;
828 typedef __atomic_base<signed char> __base_type;
829
830 atomic() noexcept= default;
831 ~atomic() noexcept = default;
832 atomic(const atomic&) = delete;
833 atomic& operator=(const atomic&) = delete;
834 atomic& operator=(const atomic&) volatile = delete;
835
836 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
837
838 using __base_type::operator __integral_type;
839 using __base_type::operator=;
840
841#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
842 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
843#endif
844 };
845
846 /// Explicit specialization for unsigned char.
847 template<>
848 struct atomic<unsigned char> : __atomic_base<unsigned char>
849 {
850 typedef unsigned char __integral_type;
851 typedef __atomic_base<unsigned char> __base_type;
852
853 atomic() noexcept= default;
854 ~atomic() noexcept = default;
855 atomic(const atomic&) = delete;
856 atomic& operator=(const atomic&) = delete;
857 atomic& operator=(const atomic&) volatile = delete;
858
859 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
860
861 using __base_type::operator __integral_type;
862 using __base_type::operator=;
863
864#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
865 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
866#endif
867 };
868
869 /// Explicit specialization for short.
870 template<>
871 struct atomic<short> : __atomic_base<short>
872 {
873 typedef short __integral_type;
874 typedef __atomic_base<short> __base_type;
875
876 atomic() noexcept = default;
877 ~atomic() noexcept = default;
878 atomic(const atomic&) = delete;
879 atomic& operator=(const atomic&) = delete;
880 atomic& operator=(const atomic&) volatile = delete;
881
882 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
883
884 using __base_type::operator __integral_type;
885 using __base_type::operator=;
886
887#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
888 static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
889#endif
890 };
891
892 /// Explicit specialization for unsigned short.
893 template<>
894 struct atomic<unsigned short> : __atomic_base<unsigned short>
895 {
896 typedef unsigned short __integral_type;
897 typedef __atomic_base<unsigned short> __base_type;
898
899 atomic() noexcept = default;
900 ~atomic() noexcept = default;
901 atomic(const atomic&) = delete;
902 atomic& operator=(const atomic&) = delete;
903 atomic& operator=(const atomic&) volatile = delete;
904
905 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
906
907 using __base_type::operator __integral_type;
908 using __base_type::operator=;
909
910#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
911 static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
912#endif
913 };
914
915 /// Explicit specialization for int.
916 template<>
917 struct atomic<int> : __atomic_base<int>
918 {
919 typedef int __integral_type;
920 typedef __atomic_base<int> __base_type;
921
922 atomic() noexcept = default;
923 ~atomic() noexcept = default;
924 atomic(const atomic&) = delete;
925 atomic& operator=(const atomic&) = delete;
926 atomic& operator=(const atomic&) volatile = delete;
927
928 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
929
930 using __base_type::operator __integral_type;
931 using __base_type::operator=;
932
933#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
934 static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
935#endif
936 };
937
938 /// Explicit specialization for unsigned int.
939 template<>
940 struct atomic<unsigned int> : __atomic_base<unsigned int>
941 {
942 typedef unsigned int __integral_type;
943 typedef __atomic_base<unsigned int> __base_type;
944
945 atomic() noexcept = default;
946 ~atomic() noexcept = default;
947 atomic(const atomic&) = delete;
948 atomic& operator=(const atomic&) = delete;
949 atomic& operator=(const atomic&) volatile = delete;
950
951 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
952
953 using __base_type::operator __integral_type;
954 using __base_type::operator=;
955
956#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
957 static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
958#endif
959 };
960
961 /// Explicit specialization for long.
962 template<>
963 struct atomic<long> : __atomic_base<long>
964 {
965 typedef long __integral_type;
966 typedef __atomic_base<long> __base_type;
967
968 atomic() noexcept = default;
969 ~atomic() noexcept = default;
970 atomic(const atomic&) = delete;
971 atomic& operator=(const atomic&) = delete;
972 atomic& operator=(const atomic&) volatile = delete;
973
974 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
975
976 using __base_type::operator __integral_type;
977 using __base_type::operator=;
978
979#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
980 static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
981#endif
982 };
983
984 /// Explicit specialization for unsigned long.
985 template<>
986 struct atomic<unsigned long> : __atomic_base<unsigned long>
987 {
988 typedef unsigned long __integral_type;
989 typedef __atomic_base<unsigned long> __base_type;
990
991 atomic() noexcept = default;
992 ~atomic() noexcept = default;
993 atomic(const atomic&) = delete;
994 atomic& operator=(const atomic&) = delete;
995 atomic& operator=(const atomic&) volatile = delete;
996
997 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
998
999 using __base_type::operator __integral_type;
1000 using __base_type::operator=;
1001
1002#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1003 static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
1004#endif
1005 };
1006
1007 /// Explicit specialization for long long.
1008 template<>
1009 struct atomic<long long> : __atomic_base<long long>
1010 {
1011 typedef long long __integral_type;
1012 typedef __atomic_base<long long> __base_type;
1013
1014 atomic() noexcept = default;
1015 ~atomic() noexcept = default;
1016 atomic(const atomic&) = delete;
1017 atomic& operator=(const atomic&) = delete;
1018 atomic& operator=(const atomic&) volatile = delete;
1019
1020 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1021
1022 using __base_type::operator __integral_type;
1023 using __base_type::operator=;
1024
1025#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1026 static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
1027#endif
1028 };
1029
1030 /// Explicit specialization for unsigned long long.
1031 template<>
1032 struct atomic<unsigned long long> : __atomic_base<unsigned long long>
1033 {
1034 typedef unsigned long long __integral_type;
1035 typedef __atomic_base<unsigned long long> __base_type;
1036
1037 atomic() noexcept = default;
1038 ~atomic() noexcept = default;
1039 atomic(const atomic&) = delete;
1040 atomic& operator=(const atomic&) = delete;
1041 atomic& operator=(const atomic&) volatile = delete;
1042
1043 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1044
1045 using __base_type::operator __integral_type;
1046 using __base_type::operator=;
1047
1048#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1049 static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
1050#endif
1051 };
1052
1053 /// Explicit specialization for wchar_t.
1054 template<>
1055 struct atomic<wchar_t> : __atomic_base<wchar_t>
1056 {
1057 typedef wchar_t __integral_type;
1058 typedef __atomic_base<wchar_t> __base_type;
1059
1060 atomic() noexcept = default;
1061 ~atomic() noexcept = default;
1062 atomic(const atomic&) = delete;
1063 atomic& operator=(const atomic&) = delete;
1064 atomic& operator=(const atomic&) volatile = delete;
1065
1066 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1067
1068 using __base_type::operator __integral_type;
1069 using __base_type::operator=;
1070
1071#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1072 static constexpr bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2;
1073#endif
1074 };
1075
1076#ifdef _GLIBCXX_USE_CHAR8_T
1077 /// Explicit specialization for char8_t.
1078 template<>
1079 struct atomic<char8_t> : __atomic_base<char8_t>
1080 {
1081 typedef char8_t __integral_type;
1082 typedef __atomic_base<char8_t> __base_type;
1083
1084 atomic() noexcept = default;
1085 ~atomic() noexcept = default;
1086 atomic(const atomic&) = delete;
1087 atomic& operator=(const atomic&) = delete;
1088 atomic& operator=(const atomic&) volatile = delete;
1089
1090 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1091
1092 using __base_type::operator __integral_type;
1093 using __base_type::operator=;
1094
1095#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1096 static constexpr bool is_always_lock_free
1097 = ATOMIC_CHAR8_T_LOCK_FREE == 2;
1098#endif
1099 };
1100#endif
1101
1102 /// Explicit specialization for char16_t.
1103 template<>
1104 struct atomic<char16_t> : __atomic_base<char16_t>
1105 {
1106 typedef char16_t __integral_type;
1107 typedef __atomic_base<char16_t> __base_type;
1108
1109 atomic() noexcept = default;
1110 ~atomic() noexcept = default;
1111 atomic(const atomic&) = delete;
1112 atomic& operator=(const atomic&) = delete;
1113 atomic& operator=(const atomic&) volatile = delete;
1114
1115 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1116
1117 using __base_type::operator __integral_type;
1118 using __base_type::operator=;
1119
1120#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1121 static constexpr bool is_always_lock_free
1122 = ATOMIC_CHAR16_T_LOCK_FREE == 2;
1123#endif
1124 };
1125
1126 /// Explicit specialization for char32_t.
1127 template<>
1128 struct atomic<char32_t> : __atomic_base<char32_t>
1129 {
1130 typedef char32_t __integral_type;
1131 typedef __atomic_base<char32_t> __base_type;
1132
1133 atomic() noexcept = default;
1134 ~atomic() noexcept = default;
1135 atomic(const atomic&) = delete;
1136 atomic& operator=(const atomic&) = delete;
1137 atomic& operator=(const atomic&) volatile = delete;
1138
1139 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1140
1141 using __base_type::operator __integral_type;
1142 using __base_type::operator=;
1143
1144#ifdef __cpp_lib_atomic_is_always_lock_free // C++ >= 17
1145 static constexpr bool is_always_lock_free
1146 = ATOMIC_CHAR32_T_LOCK_FREE == 2;
1147#endif
1148 };
1149
1150
1151 /// atomic_bool
1153
1154 /// atomic_char
1156
1157 /// atomic_schar
1159
1160 /// atomic_uchar
1162
1163 /// atomic_short
1165
1166 /// atomic_ushort
1168
1169 /// atomic_int
1171
1172 /// atomic_uint
1174
1175 /// atomic_long
1177
1178 /// atomic_ulong
1180
1181 /// atomic_llong
1183
1184 /// atomic_ullong
1186
1187 /// atomic_wchar_t
1189
1190#ifdef _GLIBCXX_USE_CHAR8_T
1191 /// atomic_char8_t
1192 typedef atomic<char8_t> atomic_char8_t;
1193#endif
1194
1195 /// atomic_char16_t
1197
1198 /// atomic_char32_t
1200
1201#ifdef _GLIBCXX_USE_C99_STDINT
1202 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1203 // 2441. Exact-width atomic typedefs should be provided
1204
1205 /// atomic_int8_t
1207
1208 /// atomic_uint8_t
1210
1211 /// atomic_int16_t
1213
1214 /// atomic_uint16_t
1216
1217 /// atomic_int32_t
1219
1220 /// atomic_uint32_t
1222
1223 /// atomic_int64_t
1225
1226 /// atomic_uint64_t
1228#endif
1229
1230 /// atomic_int_least8_t
1232
1233 /// atomic_uint_least8_t
1235
1236 /// atomic_int_least16_t
1238
1239 /// atomic_uint_least16_t
1241
1242 /// atomic_int_least32_t
1244
1245 /// atomic_uint_least32_t
1247
1248 /// atomic_int_least64_t
1250
1251 /// atomic_uint_least64_t
1253
1254
1255 /// atomic_int_fast8_t
1257
1258 /// atomic_uint_fast8_t
1260
1261 /// atomic_int_fast16_t
1263
1264 /// atomic_uint_fast16_t
1266
1267 /// atomic_int_fast32_t
1269
1270 /// atomic_uint_fast32_t
1272
1273 /// atomic_int_fast64_t
1275
1276 /// atomic_uint_fast64_t
1278
1279
1280 /// atomic_intptr_t
1282
1283 /// atomic_uintptr_t
1285
1286 /// atomic_size_t
1288
1289 /// atomic_ptrdiff_t
1291
1292 /// atomic_intmax_t
1294
1295 /// atomic_uintmax_t
1297
1298 // Function definitions, atomic_flag operations.
1299 inline bool
1300 atomic_flag_test_and_set_explicit(atomic_flag* __a,
1301 memory_order __m) noexcept
1302 { return __a->test_and_set(__m); }
1303
1304 inline bool
1305 atomic_flag_test_and_set_explicit(volatile atomic_flag* __a,
1306 memory_order __m) noexcept
1307 { return __a->test_and_set(__m); }
1308
1309#if __cpp_lib_atomic_flag_test
1310 inline bool
1311 atomic_flag_test(const atomic_flag* __a) noexcept
1312 { return __a->test(); }
1313
1314 inline bool
1315 atomic_flag_test(const volatile atomic_flag* __a) noexcept
1316 { return __a->test(); }
1317
1318 inline bool
1319 atomic_flag_test_explicit(const atomic_flag* __a,
1320 memory_order __m) noexcept
1321 { return __a->test(__m); }
1322
1323 inline bool
1324 atomic_flag_test_explicit(const volatile atomic_flag* __a,
1325 memory_order __m) noexcept
1326 { return __a->test(__m); }
1327#endif
1328
1329 inline void
1330 atomic_flag_clear_explicit(atomic_flag* __a, memory_order __m) noexcept
1331 { __a->clear(__m); }
1332
1333 inline void
1334 atomic_flag_clear_explicit(volatile atomic_flag* __a,
1335 memory_order __m) noexcept
1336 { __a->clear(__m); }
1337
1338 inline bool
1339 atomic_flag_test_and_set(atomic_flag* __a) noexcept
1340 { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1341
1342 inline bool
1343 atomic_flag_test_and_set(volatile atomic_flag* __a) noexcept
1344 { return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1345
1346 inline void
1347 atomic_flag_clear(atomic_flag* __a) noexcept
1348 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1349
1350 inline void
1351 atomic_flag_clear(volatile atomic_flag* __a) noexcept
1352 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1353
1354#if __cpp_lib_atomic_wait
1355 inline void
1356 atomic_flag_wait(atomic_flag* __a, bool __old) noexcept
1357 { __a->wait(__old); }
1358
1359 inline void
1360 atomic_flag_wait_explicit(atomic_flag* __a, bool __old,
1361 memory_order __m) noexcept
1362 { __a->wait(__old, __m); }
1363
1364 inline void
1365 atomic_flag_notify_one(atomic_flag* __a) noexcept
1366 { __a->notify_one(); }
1367
1368 inline void
1369 atomic_flag_notify_all(atomic_flag* __a) noexcept
1370 { __a->notify_all(); }
1371#endif // __cpp_lib_atomic_wait
1372
1373 /// @cond undocumented
1374 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1375 // 3220. P0558 broke conforming C++14 uses of atomic shared_ptr
1376 template<typename _Tp>
1377 using __atomic_val_t = __type_identity_t<_Tp>;
1378 template<typename _Tp>
1379 using __atomic_diff_t = typename atomic<_Tp>::difference_type;
1380 /// @endcond
1381
1382 // [atomics.nonmembers] Non-member functions.
1383 // Function templates generally applicable to atomic types.
1384 template<typename _ITp>
1385 inline bool
1386 atomic_is_lock_free(const atomic<_ITp>* __a) noexcept
1387 { return __a->is_lock_free(); }
1388
1389 template<typename _ITp>
1390 inline bool
1391 atomic_is_lock_free(const volatile atomic<_ITp>* __a) noexcept
1392 { return __a->is_lock_free(); }
1393
1394 template<typename _ITp>
1395 inline void
1396 atomic_init(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1397 { __a->store(__i, memory_order_relaxed); }
1398
1399 template<typename _ITp>
1400 inline void
1401 atomic_init(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1402 { __a->store(__i, memory_order_relaxed); }
1403
1404 template<typename _ITp>
1405 inline void
1406 atomic_store_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1407 memory_order __m) noexcept
1408 { __a->store(__i, __m); }
1409
1410 template<typename _ITp>
1411 inline void
1412 atomic_store_explicit(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1413 memory_order __m) noexcept
1414 { __a->store(__i, __m); }
1415
1416 template<typename _ITp>
1417 inline _ITp
1418 atomic_load_explicit(const atomic<_ITp>* __a, memory_order __m) noexcept
1419 { return __a->load(__m); }
1420
1421 template<typename _ITp>
1422 inline _ITp
1423 atomic_load_explicit(const volatile atomic<_ITp>* __a,
1424 memory_order __m) noexcept
1425 { return __a->load(__m); }
1426
1427 template<typename _ITp>
1428 inline _ITp
1429 atomic_exchange_explicit(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1430 memory_order __m) noexcept
1431 { return __a->exchange(__i, __m); }
1432
1433 template<typename _ITp>
1434 inline _ITp
1435 atomic_exchange_explicit(volatile atomic<_ITp>* __a,
1436 __atomic_val_t<_ITp> __i,
1437 memory_order __m) noexcept
1438 { return __a->exchange(__i, __m); }
1439
1440 template<typename _ITp>
1441 inline bool
1442 atomic_compare_exchange_weak_explicit(atomic<_ITp>* __a,
1443 __atomic_val_t<_ITp>* __i1,
1444 __atomic_val_t<_ITp> __i2,
1445 memory_order __m1,
1446 memory_order __m2) noexcept
1447 { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1448
1449 template<typename _ITp>
1450 inline bool
1451 atomic_compare_exchange_weak_explicit(volatile atomic<_ITp>* __a,
1452 __atomic_val_t<_ITp>* __i1,
1453 __atomic_val_t<_ITp> __i2,
1454 memory_order __m1,
1455 memory_order __m2) noexcept
1456 { return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1457
1458 template<typename _ITp>
1459 inline bool
1460 atomic_compare_exchange_strong_explicit(atomic<_ITp>* __a,
1461 __atomic_val_t<_ITp>* __i1,
1462 __atomic_val_t<_ITp> __i2,
1463 memory_order __m1,
1464 memory_order __m2) noexcept
1465 { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1466
1467 template<typename _ITp>
1468 inline bool
1469 atomic_compare_exchange_strong_explicit(volatile atomic<_ITp>* __a,
1470 __atomic_val_t<_ITp>* __i1,
1471 __atomic_val_t<_ITp> __i2,
1472 memory_order __m1,
1473 memory_order __m2) noexcept
1474 { return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1475
1476
1477 template<typename _ITp>
1478 inline void
1479 atomic_store(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1480 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1481
1482 template<typename _ITp>
1483 inline void
1484 atomic_store(volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1485 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1486
1487 template<typename _ITp>
1488 inline _ITp
1489 atomic_load(const atomic<_ITp>* __a) noexcept
1490 { return atomic_load_explicit(__a, memory_order_seq_cst); }
1491
1492 template<typename _ITp>
1493 inline _ITp
1494 atomic_load(const volatile atomic<_ITp>* __a) noexcept
1495 { return atomic_load_explicit(__a, memory_order_seq_cst); }
1496
1497 template<typename _ITp>
1498 inline _ITp
1499 atomic_exchange(atomic<_ITp>* __a, __atomic_val_t<_ITp> __i) noexcept
1500 { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1501
1502 template<typename _ITp>
1503 inline _ITp
1504 atomic_exchange(volatile atomic<_ITp>* __a,
1505 __atomic_val_t<_ITp> __i) noexcept
1506 { return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1507
1508 template<typename _ITp>
1509 inline bool
1510 atomic_compare_exchange_weak(atomic<_ITp>* __a,
1511 __atomic_val_t<_ITp>* __i1,
1512 __atomic_val_t<_ITp> __i2) noexcept
1513 {
1514 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1515 memory_order_seq_cst,
1516 memory_order_seq_cst);
1517 }
1518
1519 template<typename _ITp>
1520 inline bool
1521 atomic_compare_exchange_weak(volatile atomic<_ITp>* __a,
1522 __atomic_val_t<_ITp>* __i1,
1523 __atomic_val_t<_ITp> __i2) noexcept
1524 {
1525 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1526 memory_order_seq_cst,
1527 memory_order_seq_cst);
1528 }
1529
1530 template<typename _ITp>
1531 inline bool
1532 atomic_compare_exchange_strong(atomic<_ITp>* __a,
1533 __atomic_val_t<_ITp>* __i1,
1534 __atomic_val_t<_ITp> __i2) noexcept
1535 {
1536 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1537 memory_order_seq_cst,
1538 memory_order_seq_cst);
1539 }
1540
1541 template<typename _ITp>
1542 inline bool
1543 atomic_compare_exchange_strong(volatile atomic<_ITp>* __a,
1544 __atomic_val_t<_ITp>* __i1,
1545 __atomic_val_t<_ITp> __i2) noexcept
1546 {
1547 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1548 memory_order_seq_cst,
1549 memory_order_seq_cst);
1550 }
1551
1552
1553#if __cpp_lib_atomic_wait
1554 template<typename _Tp>
1555 inline void
1556 atomic_wait(const atomic<_Tp>* __a,
1557 typename std::atomic<_Tp>::value_type __old) noexcept
1558 { __a->wait(__old); }
1559
1560 template<typename _Tp>
1561 inline void
1562 atomic_wait_explicit(const atomic<_Tp>* __a,
1563 typename std::atomic<_Tp>::value_type __old,
1564 std::memory_order __m) noexcept
1565 { __a->wait(__old, __m); }
1566
1567 template<typename _Tp>
1568 inline void
1569 atomic_notify_one(atomic<_Tp>* __a) noexcept
1570 { __a->notify_one(); }
1571
1572 template<typename _Tp>
1573 inline void
1574 atomic_notify_all(atomic<_Tp>* __a) noexcept
1575 { __a->notify_all(); }
1576#endif // __cpp_lib_atomic_wait
1577
1578 // Function templates for atomic_integral and atomic_pointer operations only.
1579 // Some operations (and, or, xor) are only available for atomic integrals,
1580 // which is implemented by taking a parameter of type __atomic_base<_ITp>*.
1581
1582 template<typename _ITp>
1583 inline _ITp
1584 atomic_fetch_add_explicit(atomic<_ITp>* __a,
1585 __atomic_diff_t<_ITp> __i,
1586 memory_order __m) noexcept
1587 { return __a->fetch_add(__i, __m); }
1588
1589 template<typename _ITp>
1590 inline _ITp
1591 atomic_fetch_add_explicit(volatile atomic<_ITp>* __a,
1592 __atomic_diff_t<_ITp> __i,
1593 memory_order __m) noexcept
1594 { return __a->fetch_add(__i, __m); }
1595
1596 template<typename _ITp>
1597 inline _ITp
1598 atomic_fetch_sub_explicit(atomic<_ITp>* __a,
1599 __atomic_diff_t<_ITp> __i,
1600 memory_order __m) noexcept
1601 { return __a->fetch_sub(__i, __m); }
1602
1603 template<typename _ITp>
1604 inline _ITp
1605 atomic_fetch_sub_explicit(volatile atomic<_ITp>* __a,
1606 __atomic_diff_t<_ITp> __i,
1607 memory_order __m) noexcept
1608 { return __a->fetch_sub(__i, __m); }
1609
1610 template<typename _ITp>
1611 inline _ITp
1612 atomic_fetch_and_explicit(__atomic_base<_ITp>* __a,
1613 __atomic_val_t<_ITp> __i,
1614 memory_order __m) noexcept
1615 { return __a->fetch_and(__i, __m); }
1616
1617 template<typename _ITp>
1618 inline _ITp
1619 atomic_fetch_and_explicit(volatile __atomic_base<_ITp>* __a,
1620 __atomic_val_t<_ITp> __i,
1621 memory_order __m) noexcept
1622 { return __a->fetch_and(__i, __m); }
1623
1624 template<typename _ITp>
1625 inline _ITp
1626 atomic_fetch_or_explicit(__atomic_base<_ITp>* __a,
1627 __atomic_val_t<_ITp> __i,
1628 memory_order __m) noexcept
1629 { return __a->fetch_or(__i, __m); }
1630
1631 template<typename _ITp>
1632 inline _ITp
1633 atomic_fetch_or_explicit(volatile __atomic_base<_ITp>* __a,
1634 __atomic_val_t<_ITp> __i,
1635 memory_order __m) noexcept
1636 { return __a->fetch_or(__i, __m); }
1637
1638 template<typename _ITp>
1639 inline _ITp
1640 atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a,
1641 __atomic_val_t<_ITp> __i,
1642 memory_order __m) noexcept
1643 { return __a->fetch_xor(__i, __m); }
1644
1645 template<typename _ITp>
1646 inline _ITp
1647 atomic_fetch_xor_explicit(volatile __atomic_base<_ITp>* __a,
1648 __atomic_val_t<_ITp> __i,
1649 memory_order __m) noexcept
1650 { return __a->fetch_xor(__i, __m); }
1651
1652#ifdef __cpp_lib_atomic_min_max
1653 template<typename _Tp>
1654 inline _Tp
1655 atomic_fetch_min_explicit(atomic<_Tp>* __a,
1656 __atomic_val_t<_Tp> __i,
1657 memory_order __m) noexcept
1658 { return __a->fetch_min(__i, __m); }
1659
1660 template<typename _Tp>
1661 inline _Tp
1662 atomic_fetch_min_explicit(volatile atomic<_Tp>* __a,
1663 __atomic_val_t<_Tp> __i,
1664 memory_order __m) noexcept
1665 { return __a->fetch_min(__i, __m); }
1666
1667 template<typename _Tp>
1668 inline _Tp
1669 atomic_fetch_max_explicit(atomic<_Tp>* __a,
1670 __atomic_val_t<_Tp> __i,
1671 memory_order __m) noexcept
1672 { return __a->fetch_max(__i, __m); }
1673
1674 template<typename _Tp>
1675 inline _Tp
1676 atomic_fetch_max_explicit(volatile atomic<_Tp>* __a,
1677 __atomic_val_t<_Tp> __i,
1678 memory_order __m) noexcept
1679 { return __a->fetch_max(__i, __m); }
1680#endif
1681
1682 template<typename _ITp>
1683 inline _ITp
1684 atomic_fetch_add(atomic<_ITp>* __a,
1685 __atomic_diff_t<_ITp> __i) noexcept
1686 { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1687
1688 template<typename _ITp>
1689 inline _ITp
1690 atomic_fetch_add(volatile atomic<_ITp>* __a,
1691 __atomic_diff_t<_ITp> __i) noexcept
1692 { return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1693
1694 template<typename _ITp>
1695 inline _ITp
1696 atomic_fetch_sub(atomic<_ITp>* __a,
1697 __atomic_diff_t<_ITp> __i) noexcept
1698 { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1699
1700 template<typename _ITp>
1701 inline _ITp
1702 atomic_fetch_sub(volatile atomic<_ITp>* __a,
1703 __atomic_diff_t<_ITp> __i) noexcept
1704 { return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1705
1706 template<typename _ITp>
1707 inline _ITp
1708 atomic_fetch_and(__atomic_base<_ITp>* __a,
1709 __atomic_val_t<_ITp> __i) noexcept
1710 { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1711
1712 template<typename _ITp>
1713 inline _ITp
1714 atomic_fetch_and(volatile __atomic_base<_ITp>* __a,
1715 __atomic_val_t<_ITp> __i) noexcept
1716 { return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1717
1718 template<typename _ITp>
1719 inline _ITp
1720 atomic_fetch_or(__atomic_base<_ITp>* __a,
1721 __atomic_val_t<_ITp> __i) noexcept
1722 { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1723
1724 template<typename _ITp>
1725 inline _ITp
1726 atomic_fetch_or(volatile __atomic_base<_ITp>* __a,
1727 __atomic_val_t<_ITp> __i) noexcept
1728 { return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1729
1730 template<typename _ITp>
1731 inline _ITp
1732 atomic_fetch_xor(__atomic_base<_ITp>* __a,
1733 __atomic_val_t<_ITp> __i) noexcept
1734 { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1735
1736 template<typename _ITp>
1737 inline _ITp
1738 atomic_fetch_xor(volatile __atomic_base<_ITp>* __a,
1739 __atomic_val_t<_ITp> __i) noexcept
1740 { return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1741
1742#ifdef __cpp_lib_atomic_min_max
1743 template<typename _Tp>
1744 inline _Tp
1745 atomic_fetch_min(atomic<_Tp>* __a,
1746 __atomic_val_t<_Tp> __i) noexcept
1747 { return atomic_fetch_min_explicit(__a, __i, memory_order_seq_cst); }
1748
1749 template<typename _Tp>
1750 inline _Tp
1751 atomic_fetch_min(volatile atomic<_Tp>* __a,
1752 __atomic_val_t<_Tp> __i) noexcept
1753 { return atomic_fetch_min_explicit(__a, __i, memory_order_seq_cst); }
1754
1755 template<typename _Tp>
1756 inline _Tp
1757 atomic_fetch_max(atomic<_Tp>* __a,
1758 __atomic_val_t<_Tp> __i) noexcept
1759 { return atomic_fetch_max_explicit(__a, __i, memory_order_seq_cst); }
1760
1761 template<typename _Tp>
1762 inline _Tp
1763 atomic_fetch_max(volatile atomic<_Tp>* __a,
1764 __atomic_val_t<_Tp> __i) noexcept
1765 { return atomic_fetch_max_explicit(__a, __i, memory_order_seq_cst); }
1766#endif
1767
1768#ifdef __cpp_lib_atomic_float
1769 template<>
1770 struct atomic<float> : __atomic_float<float>
1771 {
1772 atomic() noexcept = default;
1773
1774 constexpr
1775 atomic(float __fp) noexcept : __atomic_float<float>(__fp)
1776 { }
1777
1778 atomic& operator=(const atomic&) volatile = delete;
1779 atomic& operator=(const atomic&) = delete;
1780
1781 using __atomic_float<float>::operator=;
1782 };
1783
1784 template<>
1785 struct atomic<double> : __atomic_float<double>
1786 {
1787 atomic() noexcept = default;
1788
1789 constexpr
1790 atomic(double __fp) noexcept : __atomic_float<double>(__fp)
1791 { }
1792
1793 atomic& operator=(const atomic&) volatile = delete;
1794 atomic& operator=(const atomic&) = delete;
1795
1796 using __atomic_float<double>::operator=;
1797 };
1798
1799 template<>
1800 struct atomic<long double> : __atomic_float<long double>
1801 {
1802 atomic() noexcept = default;
1803
1804 constexpr
1805 atomic(long double __fp) noexcept : __atomic_float<long double>(__fp)
1806 { }
1807
1808 atomic& operator=(const atomic&) volatile = delete;
1809 atomic& operator=(const atomic&) = delete;
1810
1811 using __atomic_float<long double>::operator=;
1812 };
1813
1814#ifdef __STDCPP_FLOAT16_T__
1815 template<>
1816 struct atomic<_Float16> : __atomic_float<_Float16>
1817 {
1818 atomic() noexcept = default;
1819
1820 constexpr
1821 atomic(_Float16 __fp) noexcept : __atomic_float<_Float16>(__fp)
1822 { }
1823
1824 atomic& operator=(const atomic&) volatile = delete;
1825 atomic& operator=(const atomic&) = delete;
1826
1827 using __atomic_float<_Float16>::operator=;
1828 };
1829#endif
1830
1831#ifdef __STDCPP_FLOAT32_T__
1832 template<>
1833 struct atomic<_Float32> : __atomic_float<_Float32>
1834 {
1835 atomic() noexcept = default;
1836
1837 constexpr
1838 atomic(_Float32 __fp) noexcept : __atomic_float<_Float32>(__fp)
1839 { }
1840
1841 atomic& operator=(const atomic&) volatile = delete;
1842 atomic& operator=(const atomic&) = delete;
1843
1844 using __atomic_float<_Float32>::operator=;
1845 };
1846#endif
1847
1848#ifdef __STDCPP_FLOAT64_T__
1849 template<>
1850 struct atomic<_Float64> : __atomic_float<_Float64>
1851 {
1852 atomic() noexcept = default;
1853
1854 constexpr
1855 atomic(_Float64 __fp) noexcept : __atomic_float<_Float64>(__fp)
1856 { }
1857
1858 atomic& operator=(const atomic&) volatile = delete;
1859 atomic& operator=(const atomic&) = delete;
1860
1861 using __atomic_float<_Float64>::operator=;
1862 };
1863#endif
1864
1865#ifdef __STDCPP_FLOAT128_T__
1866 template<>
1867 struct atomic<_Float128> : __atomic_float<_Float128>
1868 {
1869 atomic() noexcept = default;
1870
1871 constexpr
1872 atomic(_Float128 __fp) noexcept : __atomic_float<_Float128>(__fp)
1873 { }
1874
1875 atomic& operator=(const atomic&) volatile = delete;
1876 atomic& operator=(const atomic&) = delete;
1877
1878 using __atomic_float<_Float128>::operator=;
1879 };
1880#endif
1881
1882#ifdef __STDCPP_BFLOAT16_T__
1883 template<>
1884 struct atomic<__gnu_cxx::__bfloat16_t> : __atomic_float<__gnu_cxx::__bfloat16_t>
1885 {
1886 atomic() noexcept = default;
1887
1888 constexpr
1889 atomic(__gnu_cxx::__bfloat16_t __fp) noexcept : __atomic_float<__gnu_cxx::__bfloat16_t>(__fp)
1890 { }
1891
1892 atomic& operator=(const atomic&) volatile = delete;
1893 atomic& operator=(const atomic&) = delete;
1894
1895 using __atomic_float<__gnu_cxx::__bfloat16_t>::operator=;
1896 };
1897#endif
1898#endif // __cpp_lib_atomic_float
1899
1900#ifdef __cpp_lib_atomic_ref
1901 /// Class template to provide atomic operations on a non-atomic variable.
1902 template<typename _Tp>
1903 struct atomic_ref : __atomic_ref<_Tp>
1904 {
1905 explicit
1906 atomic_ref(_Tp& __t) noexcept
1907 : __atomic_ref<_Tp>(std::addressof(__t))
1908 {
1909 __glibcxx_assert(((__UINTPTR_TYPE__)this->_M_ptr % this->required_alignment) == 0);
1910 }
1911
1912 // _GLIBCXX_RESOLVE_LIB_DEFECTS
1913 // 4472. std::atomic_ref<const T> can be constructed from temporaries
1914 explicit
1915 atomic_ref(_Tp&&) = delete;
1916
1917 template<typename _Up>
1918 requires is_convertible_v<_Up(*)[1], _Tp(*)[1]>
1919 atomic_ref(atomic_ref<_Up> __other) noexcept
1920 : __atomic_ref<_Tp>(__other._M_ptr)
1921 { }
1922
1923 atomic_ref& operator=(const atomic_ref&) = delete;
1924
1925 atomic_ref(const atomic_ref&) = default;
1926
1927 using __atomic_ref<_Tp>::operator=;
1928
1929 template<typename>
1930 friend struct atomic_ref;
1931 };
1932#endif // __cpp_lib_atomic_ref
1933
1934#ifdef __cpp_lib_atomic_lock_free_type_aliases
1935# ifdef _GLIBCXX_HAVE_PLATFORM_WAIT
1936 using atomic_signed_lock_free
1938 using atomic_unsigned_lock_free
1940# elif ATOMIC_INT_LOCK_FREE == 2
1941 using atomic_signed_lock_free = atomic<signed int>;
1942 using atomic_unsigned_lock_free = atomic<unsigned int>;
1943# elif ATOMIC_LONG_LOCK_FREE == 2
1944 using atomic_signed_lock_free = atomic<signed long>;
1945 using atomic_unsigned_lock_free = atomic<unsigned long>;
1946# elif ATOMIC_CHAR_LOCK_FREE == 2
1947 using atomic_signed_lock_free = atomic<signed char>;
1948 using atomic_unsigned_lock_free = atomic<unsigned char>;
1949# else
1950# error "libstdc++ bug: no lock-free atomics but they were emitted in <version>"
1951# endif
1952#endif
1953
1954 /// @} group atomics
1955
1956_GLIBCXX_END_NAMESPACE_VERSION
1957} // namespace
1958
1959#endif // C++11
1960
1961#endif // _GLIBCXX_ATOMIC
constexpr _Tp * addressof(_Tp &__r) noexcept
Returns the actual address of the object or function referenced by r, even in the presence of an over...
Definition move.h:176
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
Definition move.h:52
atomic< unsigned long > atomic_ulong
atomic_ulong
Definition atomic:1179
atomic< intmax_t > atomic_intmax_t
atomic_intmax_t
Definition atomic:1293
atomic< uintptr_t > atomic_uintptr_t
atomic_uintptr_t
Definition atomic:1284
atomic< signed char > atomic_schar
atomic_schar
Definition atomic:1158
atomic< int_least8_t > atomic_int_least8_t
atomic_int_least8_t
Definition atomic:1231
atomic< unsigned long long > atomic_ullong
atomic_ullong
Definition atomic:1185
atomic< uint_fast8_t > atomic_uint_fast8_t
atomic_uint_fast8_t
Definition atomic:1259
atomic< intptr_t > atomic_intptr_t
atomic_intptr_t
Definition atomic:1281
atomic< int16_t > atomic_int16_t
atomic_int16_t
Definition atomic:1212
atomic< size_t > atomic_size_t
atomic_size_t
Definition atomic:1287
atomic< long > atomic_long
atomic_long
Definition atomic:1176
atomic< uint_least8_t > atomic_uint_least8_t
atomic_uint_least8_t
Definition atomic:1234
atomic< short > atomic_short
atomic_short
Definition atomic:1164
atomic< uint_least16_t > atomic_uint_least16_t
atomic_uint_least16_t
Definition atomic:1240
atomic< uint16_t > atomic_uint16_t
atomic_uint16_t
Definition atomic:1215
atomic< uint64_t > atomic_uint64_t
atomic_uint64_t
Definition atomic:1227
atomic< int_least32_t > atomic_int_least32_t
atomic_int_least32_t
Definition atomic:1243
atomic< uint8_t > atomic_uint8_t
atomic_uint8_t
Definition atomic:1209
#define ATOMIC_BOOL_LOCK_FREE
atomic< wchar_t > atomic_wchar_t
atomic_wchar_t
Definition atomic:1188
atomic< unsigned int > atomic_uint
atomic_uint
Definition atomic:1173
atomic< uint_least32_t > atomic_uint_least32_t
atomic_uint_least32_t
Definition atomic:1246
atomic< uint_fast64_t > atomic_uint_fast64_t
atomic_uint_fast64_t
Definition atomic:1277
atomic< int_fast32_t > atomic_int_fast32_t
atomic_int_fast32_t
Definition atomic:1268
atomic< char > atomic_char
atomic_char
Definition atomic:1155
atomic< int > atomic_int
atomic_int
Definition atomic:1170
atomic< uint_least64_t > atomic_uint_least64_t
atomic_uint_least64_t
Definition atomic:1252
atomic< int64_t > atomic_int64_t
atomic_int64_t
Definition atomic:1224
atomic< uintmax_t > atomic_uintmax_t
atomic_uintmax_t
Definition atomic:1296
atomic< int_fast16_t > atomic_int_fast16_t
atomic_int_fast16_t
Definition atomic:1262
atomic< int32_t > atomic_int32_t
atomic_int32_t
Definition atomic:1218
atomic< uint_fast16_t > atomic_uint_fast16_t
atomic_uint_fast16_t
Definition atomic:1265
atomic< int8_t > atomic_int8_t
atomic_int8_t
Definition atomic:1206
atomic< long long > atomic_llong
atomic_llong
Definition atomic:1182
atomic< char16_t > atomic_char16_t
atomic_char16_t
Definition atomic:1196
atomic< int_fast64_t > atomic_int_fast64_t
atomic_int_fast64_t
Definition atomic:1274
atomic< ptrdiff_t > atomic_ptrdiff_t
atomic_ptrdiff_t
Definition atomic:1290
atomic< char32_t > atomic_char32_t
atomic_char32_t
Definition atomic:1199
atomic< int_least16_t > atomic_int_least16_t
atomic_int_least16_t
Definition atomic:1237
atomic< unsigned char > atomic_uchar
atomic_uchar
Definition atomic:1161
atomic< int_fast8_t > atomic_int_fast8_t
atomic_int_fast8_t
Definition atomic:1256
memory_order
Enumeration for memory_order.
Definition atomic_base.h:66
atomic< unsigned short > atomic_ushort
atomic_ushort
Definition atomic:1167
atomic< int_least64_t > atomic_int_least64_t
atomic_int_least64_t
Definition atomic:1249
atomic< bool > atomic_bool
atomic_bool
Definition atomic:1152
atomic< uint_fast32_t > atomic_uint_fast32_t
atomic_uint_fast32_t
Definition atomic:1271
atomic< uint32_t > atomic_uint32_t
atomic_uint32_t
Definition atomic:1221
ISO C++ entities toplevel namespace is std.
Generic atomic type, primary class template.
Definition atomic:216
atomic_flag