32#ifndef _GLIBCXX_ATOMIC
33#define _GLIBCXX_ATOMIC 1
36#pragma GCC system_header
39#if __cplusplus < 201103L
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_ref
47#define __glibcxx_want_atomic_lock_free_type_aliases
48#define __glibcxx_want_atomic_value_initialization
49#define __glibcxx_want_atomic_wait
56namespace std _GLIBCXX_VISIBILITY(default)
58_GLIBCXX_BEGIN_NAMESPACE_VERSION
65 template<
typename _Tp>
73 using value_type = bool;
76 __atomic_base<bool> _M_base;
79 atomic() noexcept = default;
80 ~atomic() noexcept = default;
81 atomic(const atomic&) = delete;
82 atomic& operator=(const atomic&) = delete;
83 atomic& operator=(const atomic&) volatile = delete;
85 constexpr atomic(
bool __i) noexcept : _M_base(__i) { }
88 operator=(
bool __i)
noexcept
89 {
return _M_base.operator=(__i); }
92 operator=(
bool __i)
volatile noexcept
93 {
return _M_base.operator=(__i); }
95 operator bool() const noexcept
96 {
return _M_base.load(); }
98 operator bool() const volatile noexcept
99 {
return _M_base.load(); }
102 is_lock_free() const noexcept {
return _M_base.is_lock_free(); }
105 is_lock_free() const volatile noexcept {
return _M_base.is_lock_free(); }
107#ifdef __cpp_lib_atomic_is_always_lock_free
112 store(
bool __i,
memory_order __m = memory_order_seq_cst)
noexcept
113 { _M_base.store(__i, __m); }
116 store(
bool __i,
memory_order __m = memory_order_seq_cst)
volatile noexcept
117 { _M_base.store(__i, __m); }
120 load(
memory_order __m = memory_order_seq_cst)
const noexcept
121 {
return _M_base.load(__m); }
124 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
125 {
return _M_base.load(__m); }
128 exchange(
bool __i,
memory_order __m = memory_order_seq_cst)
noexcept
129 {
return _M_base.exchange(__i, __m); }
133 memory_order __m = memory_order_seq_cst)
volatile noexcept
134 {
return _M_base.exchange(__i, __m); }
137 compare_exchange_weak(
bool& __i1,
bool __i2,
memory_order __m1,
139 {
return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
142 compare_exchange_weak(
bool& __i1,
bool __i2,
memory_order __m1,
144 {
return _M_base.compare_exchange_weak(__i1, __i2, __m1, __m2); }
147 compare_exchange_weak(
bool& __i1,
bool __i2,
149 {
return _M_base.compare_exchange_weak(__i1, __i2, __m); }
152 compare_exchange_weak(
bool& __i1,
bool __i2,
153 memory_order __m = memory_order_seq_cst)
volatile noexcept
154 {
return _M_base.compare_exchange_weak(__i1, __i2, __m); }
157 compare_exchange_strong(
bool& __i1,
bool __i2,
memory_order __m1,
159 {
return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
162 compare_exchange_strong(
bool& __i1,
bool __i2,
memory_order __m1,
164 {
return _M_base.compare_exchange_strong(__i1, __i2, __m1, __m2); }
167 compare_exchange_strong(
bool& __i1,
bool __i2,
169 {
return _M_base.compare_exchange_strong(__i1, __i2, __m); }
172 compare_exchange_strong(
bool& __i1,
bool __i2,
173 memory_order __m = memory_order_seq_cst)
volatile noexcept
174 {
return _M_base.compare_exchange_strong(__i1, __i2, __m); }
176#if __cpp_lib_atomic_wait
178 wait(
bool __old,
memory_order __m = memory_order_seq_cst)
const noexcept
179 { _M_base.wait(__old, __m); }
184 notify_one() noexcept
185 { _M_base.notify_one(); }
188 notify_all() noexcept
189 { _M_base.notify_all(); }
198 template<
typename _Tp>
201 using value_type = _Tp;
205 static constexpr int _S_min_alignment
206 = (
sizeof(_Tp) & (
sizeof(_Tp) - 1)) ||
sizeof(_Tp) > 16
209 static constexpr int _S_alignment
210 = _S_min_alignment >
alignof(_Tp) ? _S_min_alignment :
alignof(_Tp);
212 alignas(_S_alignment) _Tp _M_i;
214 static_assert(__is_trivially_copyable(_Tp),
215 "std::atomic requires a trivially copyable type");
217 static_assert(
sizeof(_Tp) > 0,
218 "Incomplete or zero-sized types are not supported");
223 "template argument for std::atomic must not be const or volatile");
225#if __cplusplus > 201703L
226 static_assert(is_copy_constructible_v<_Tp>);
227 static_assert(is_move_constructible_v<_Tp>);
228 static_assert(is_copy_assignable_v<_Tp>);
229 static_assert(is_move_assignable_v<_Tp>);
233#if __cpp_lib_atomic_value_initialization
236 constexpr atomic()
noexcept(is_nothrow_default_constructible_v<_Tp>)
237 requires is_default_constructible_v<_Tp>
244 ~atomic()
noexcept =
default;
245 atomic(
const atomic&) =
delete;
246 atomic& operator=(
const atomic&) =
delete;
247 atomic& operator=(
const atomic&)
volatile =
delete;
249 constexpr atomic(_Tp __i) noexcept : _M_i(__i)
251#if __cplusplus >= 201402L && __has_builtin(__builtin_clear_padding)
252 if _GLIBCXX17_CONSTEXPR (__atomic_impl::__maybe_has_padding<_Tp>())
257 operator _Tp()
const noexcept
260 operator _Tp()
const volatile noexcept
264 operator=(_Tp __i)
noexcept
265 { store(__i);
return __i; }
268 operator=(_Tp __i)
volatile noexcept
269 { store(__i);
return __i; }
272 is_lock_free()
const noexcept
275 return __atomic_is_lock_free(
sizeof(_M_i),
276 reinterpret_cast<void *
>(-_S_alignment));
280 is_lock_free()
const volatile noexcept
283 return __atomic_is_lock_free(
sizeof(_M_i),
284 reinterpret_cast<void *
>(-_S_alignment));
287#ifdef __cpp_lib_atomic_is_always_lock_free
288 static constexpr bool is_always_lock_free
289 = __atomic_always_lock_free(
sizeof(_M_i), 0);
293 store(_Tp __i,
memory_order __m = memory_order_seq_cst)
noexcept
296 __atomic_impl::__clear_padding(__i),
301 store(_Tp __i,
memory_order __m = memory_order_seq_cst)
volatile noexcept
304 __atomic_impl::__clear_padding(__i),
309 load(
memory_order __m = memory_order_seq_cst)
const noexcept
311 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
312 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
318 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
320 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
321 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
327 exchange(_Tp __i,
memory_order __m = memory_order_seq_cst)
noexcept
329 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
330 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
332 __atomic_impl::__clear_padding(__i),
339 memory_order __m = memory_order_seq_cst)
volatile noexcept
341 alignas(_Tp)
unsigned char __buf[
sizeof(_Tp)];
342 _Tp* __ptr =
reinterpret_cast<_Tp*
>(__buf);
344 __atomic_impl::__clear_padding(__i),
350 compare_exchange_weak(_Tp& __e, _Tp __i,
memory_order __s,
353 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
true,
358 compare_exchange_weak(_Tp& __e, _Tp __i,
memory_order __s,
361 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
true,
366 compare_exchange_weak(_Tp& __e, _Tp __i,
368 {
return compare_exchange_weak(__e, __i, __m,
369 __cmpexch_failure_order(__m)); }
372 compare_exchange_weak(_Tp& __e, _Tp __i,
373 memory_order __m = memory_order_seq_cst)
volatile noexcept
374 {
return compare_exchange_weak(__e, __i, __m,
375 __cmpexch_failure_order(__m)); }
378 compare_exchange_strong(_Tp& __e, _Tp __i,
memory_order __s,
381 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
false,
386 compare_exchange_strong(_Tp& __e, _Tp __i,
memory_order __s,
389 return __atomic_impl::__compare_exchange(_M_i, __e, __i,
false,
394 compare_exchange_strong(_Tp& __e, _Tp __i,
396 {
return compare_exchange_strong(__e, __i, __m,
397 __cmpexch_failure_order(__m)); }
400 compare_exchange_strong(_Tp& __e, _Tp __i,
401 memory_order __m = memory_order_seq_cst)
volatile noexcept
402 {
return compare_exchange_strong(__e, __i, __m,
403 __cmpexch_failure_order(__m)); }
405#if __cpp_lib_atomic_wait
407 wait(_Tp __old,
memory_order __m = memory_order_seq_cst)
const noexcept
409 std::__atomic_wait_address_v(&_M_i, __old,
410 [__m,
this] {
return this->load(__m); });
416 notify_one()
noexcept
417 { std::__atomic_notify_address(&_M_i,
false); }
420 notify_all()
noexcept
421 { std::__atomic_notify_address(&_M_i,
true); }
427 template<
typename _Tp>
430 using value_type = _Tp*;
431 using difference_type = ptrdiff_t;
433 typedef _Tp* __pointer_type;
434 typedef __atomic_base<_Tp*> __base_type;
437 atomic()
noexcept =
default;
438 ~atomic()
noexcept =
default;
439 atomic(
const atomic&) =
delete;
440 atomic& operator=(
const atomic&) =
delete;
441 atomic& operator=(
const atomic&)
volatile =
delete;
443 constexpr atomic(__pointer_type __p) noexcept : _M_b(__p) { }
445 operator __pointer_type()
const noexcept
446 {
return __pointer_type(_M_b); }
448 operator __pointer_type()
const volatile noexcept
449 {
return __pointer_type(_M_b); }
452 operator=(__pointer_type __p)
noexcept
453 {
return _M_b.operator=(__p); }
456 operator=(__pointer_type __p)
volatile noexcept
457 {
return _M_b.operator=(__p); }
460 operator++(
int)
noexcept
462#if __cplusplus >= 201703L
463 static_assert( is_object_v<_Tp>,
"pointer to object type" );
469 operator++(
int)
volatile noexcept
471#if __cplusplus >= 201703L
472 static_assert( is_object_v<_Tp>,
"pointer to object type" );
478 operator--(
int)
noexcept
480#if __cplusplus >= 201703L
481 static_assert( is_object_v<_Tp>,
"pointer to object type" );
487 operator--(
int)
volatile noexcept
489#if __cplusplus >= 201703L
490 static_assert( is_object_v<_Tp>,
"pointer to object type" );
496 operator++()
noexcept
498#if __cplusplus >= 201703L
499 static_assert( is_object_v<_Tp>,
"pointer to object type" );
505 operator++()
volatile noexcept
507#if __cplusplus >= 201703L
508 static_assert( is_object_v<_Tp>,
"pointer to object type" );
514 operator--()
noexcept
516#if __cplusplus >= 201703L
517 static_assert( is_object_v<_Tp>,
"pointer to object type" );
523 operator--()
volatile noexcept
525#if __cplusplus >= 201703L
526 static_assert( is_object_v<_Tp>,
"pointer to object type" );
532 operator+=(ptrdiff_t __d)
noexcept
534#if __cplusplus >= 201703L
535 static_assert( is_object_v<_Tp>,
"pointer to object type" );
537 return _M_b.operator+=(__d);
541 operator+=(ptrdiff_t __d)
volatile noexcept
543#if __cplusplus >= 201703L
544 static_assert( is_object_v<_Tp>,
"pointer to object type" );
546 return _M_b.operator+=(__d);
550 operator-=(ptrdiff_t __d)
noexcept
552#if __cplusplus >= 201703L
553 static_assert( is_object_v<_Tp>,
"pointer to object type" );
555 return _M_b.operator-=(__d);
559 operator-=(ptrdiff_t __d)
volatile noexcept
561#if __cplusplus >= 201703L
562 static_assert( is_object_v<_Tp>,
"pointer to object type" );
564 return _M_b.operator-=(__d);
568 is_lock_free()
const noexcept
569 {
return _M_b.is_lock_free(); }
572 is_lock_free()
const volatile noexcept
573 {
return _M_b.is_lock_free(); }
575#ifdef __cpp_lib_atomic_is_always_lock_free
576 static constexpr bool is_always_lock_free
577 = ATOMIC_POINTER_LOCK_FREE == 2;
581 store(__pointer_type __p,
583 {
return _M_b.store(__p, __m); }
586 store(__pointer_type __p,
587 memory_order __m = memory_order_seq_cst)
volatile noexcept
588 {
return _M_b.store(__p, __m); }
591 load(
memory_order __m = memory_order_seq_cst)
const noexcept
592 {
return _M_b.load(__m); }
595 load(
memory_order __m = memory_order_seq_cst)
const volatile noexcept
596 {
return _M_b.load(__m); }
599 exchange(__pointer_type __p,
601 {
return _M_b.exchange(__p, __m); }
604 exchange(__pointer_type __p,
605 memory_order __m = memory_order_seq_cst)
volatile noexcept
606 {
return _M_b.exchange(__p, __m); }
609 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
611 {
return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
614 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
617 {
return _M_b.compare_exchange_weak(__p1, __p2, __m1, __m2); }
620 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
623 return compare_exchange_weak(__p1, __p2, __m,
624 __cmpexch_failure_order(__m));
628 compare_exchange_weak(__pointer_type& __p1, __pointer_type __p2,
629 memory_order __m = memory_order_seq_cst)
volatile noexcept
631 return compare_exchange_weak(__p1, __p2, __m,
632 __cmpexch_failure_order(__m));
636 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
638 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
641 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
644 {
return _M_b.compare_exchange_strong(__p1, __p2, __m1, __m2); }
647 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
650 return _M_b.compare_exchange_strong(__p1, __p2, __m,
651 __cmpexch_failure_order(__m));
655 compare_exchange_strong(__pointer_type& __p1, __pointer_type __p2,
656 memory_order __m = memory_order_seq_cst)
volatile noexcept
658 return _M_b.compare_exchange_strong(__p1, __p2, __m,
659 __cmpexch_failure_order(__m));
662#if __cpp_lib_atomic_wait
664 wait(__pointer_type __old,
memory_order __m = memory_order_seq_cst)
const noexcept
665 { _M_b.wait(__old, __m); }
670 notify_one()
noexcept
671 { _M_b.notify_one(); }
674 notify_all()
noexcept
675 { _M_b.notify_all(); }
679 fetch_add(ptrdiff_t __d,
682#if __cplusplus >= 201703L
683 static_assert( is_object_v<_Tp>,
"pointer to object type" );
685 return _M_b.fetch_add(__d, __m);
689 fetch_add(ptrdiff_t __d,
690 memory_order __m = memory_order_seq_cst)
volatile noexcept
692#if __cplusplus >= 201703L
693 static_assert( is_object_v<_Tp>,
"pointer to object type" );
695 return _M_b.fetch_add(__d, __m);
699 fetch_sub(ptrdiff_t __d,
702#if __cplusplus >= 201703L
703 static_assert( is_object_v<_Tp>,
"pointer to object type" );
705 return _M_b.fetch_sub(__d, __m);
709 fetch_sub(ptrdiff_t __d,
710 memory_order __m = memory_order_seq_cst)
volatile noexcept
712#if __cplusplus >= 201703L
713 static_assert( is_object_v<_Tp>,
"pointer to object type" );
715 return _M_b.fetch_sub(__d, __m);
722 struct atomic<char> : __atomic_base<char>
724 typedef char __integral_type;
725 typedef __atomic_base<char> __base_type;
727 atomic() noexcept = default;
728 ~
atomic() noexcept = default;
733 constexpr
atomic(__integral_type __i) noexcept : __base_type(__i) { }
735 using __base_type::operator __integral_type;
736 using __base_type::operator=;
738#ifdef __cpp_lib_atomic_is_always_lock_free
739 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
745 struct atomic<signed char> : __atomic_base<signed char>
747 typedef signed char __integral_type;
748 typedef __atomic_base<signed char> __base_type;
750 atomic() noexcept= default;
751 ~atomic() noexcept = default;
752 atomic(const atomic&) = delete;
753 atomic& operator=(const atomic&) = delete;
754 atomic& operator=(const atomic&) volatile = delete;
756 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
758 using __base_type::operator __integral_type;
759 using __base_type::operator=;
761#ifdef __cpp_lib_atomic_is_always_lock_free
762 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
768 struct atomic<unsigned char> : __atomic_base<unsigned char>
770 typedef unsigned char __integral_type;
771 typedef __atomic_base<unsigned char> __base_type;
773 atomic() noexcept= default;
774 ~atomic() noexcept = default;
775 atomic(const atomic&) = delete;
776 atomic& operator=(const atomic&) = delete;
777 atomic& operator=(const atomic&) volatile = delete;
779 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
781 using __base_type::operator __integral_type;
782 using __base_type::operator=;
784#ifdef __cpp_lib_atomic_is_always_lock_free
785 static constexpr bool is_always_lock_free = ATOMIC_CHAR_LOCK_FREE == 2;
791 struct atomic<short> : __atomic_base<short>
793 typedef short __integral_type;
794 typedef __atomic_base<short> __base_type;
796 atomic() noexcept = default;
797 ~atomic() noexcept = default;
798 atomic(const atomic&) = delete;
799 atomic& operator=(const atomic&) = delete;
800 atomic& operator=(const atomic&) volatile = delete;
802 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
804 using __base_type::operator __integral_type;
805 using __base_type::operator=;
807#ifdef __cpp_lib_atomic_is_always_lock_free
808 static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
814 struct atomic<unsigned short> : __atomic_base<unsigned short>
816 typedef unsigned short __integral_type;
817 typedef __atomic_base<unsigned short> __base_type;
819 atomic() noexcept = default;
820 ~atomic() noexcept = default;
821 atomic(const atomic&) = delete;
822 atomic& operator=(const atomic&) = delete;
823 atomic& operator=(const atomic&) volatile = delete;
825 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
827 using __base_type::operator __integral_type;
828 using __base_type::operator=;
830#ifdef __cpp_lib_atomic_is_always_lock_free
831 static constexpr bool is_always_lock_free = ATOMIC_SHORT_LOCK_FREE == 2;
837 struct atomic<int> : __atomic_base<int>
839 typedef int __integral_type;
840 typedef __atomic_base<int> __base_type;
842 atomic() noexcept = default;
843 ~atomic() noexcept = default;
844 atomic(const atomic&) = delete;
845 atomic& operator=(const atomic&) = delete;
846 atomic& operator=(const atomic&) volatile = delete;
848 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
850 using __base_type::operator __integral_type;
851 using __base_type::operator=;
853#ifdef __cpp_lib_atomic_is_always_lock_free
854 static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
860 struct atomic<unsigned int> : __atomic_base<unsigned int>
862 typedef unsigned int __integral_type;
863 typedef __atomic_base<unsigned int> __base_type;
865 atomic() noexcept = default;
866 ~atomic() noexcept = default;
867 atomic(const atomic&) = delete;
868 atomic& operator=(const atomic&) = delete;
869 atomic& operator=(const atomic&) volatile = delete;
871 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
873 using __base_type::operator __integral_type;
874 using __base_type::operator=;
876#ifdef __cpp_lib_atomic_is_always_lock_free
877 static constexpr bool is_always_lock_free = ATOMIC_INT_LOCK_FREE == 2;
883 struct atomic<long> : __atomic_base<long>
885 typedef long __integral_type;
886 typedef __atomic_base<long> __base_type;
888 atomic() noexcept = default;
889 ~atomic() noexcept = default;
890 atomic(const atomic&) = delete;
891 atomic& operator=(const atomic&) = delete;
892 atomic& operator=(const atomic&) volatile = delete;
894 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
896 using __base_type::operator __integral_type;
897 using __base_type::operator=;
899#ifdef __cpp_lib_atomic_is_always_lock_free
900 static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
906 struct atomic<unsigned long> : __atomic_base<unsigned long>
908 typedef unsigned long __integral_type;
909 typedef __atomic_base<unsigned long> __base_type;
911 atomic() noexcept = default;
912 ~atomic() noexcept = default;
913 atomic(const atomic&) = delete;
914 atomic& operator=(const atomic&) = delete;
915 atomic& operator=(const atomic&) volatile = delete;
917 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
919 using __base_type::operator __integral_type;
920 using __base_type::operator=;
922#ifdef __cpp_lib_atomic_is_always_lock_free
923 static constexpr bool is_always_lock_free = ATOMIC_LONG_LOCK_FREE == 2;
929 struct atomic<long long> : __atomic_base<long long>
931 typedef long long __integral_type;
932 typedef __atomic_base<long long> __base_type;
934 atomic() noexcept = default;
935 ~atomic() noexcept = default;
936 atomic(const atomic&) = delete;
937 atomic& operator=(const atomic&) = delete;
938 atomic& operator=(const atomic&) volatile = delete;
940 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
942 using __base_type::operator __integral_type;
943 using __base_type::operator=;
945#ifdef __cpp_lib_atomic_is_always_lock_free
946 static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
952 struct atomic<unsigned long long> : __atomic_base<unsigned long long>
954 typedef unsigned long long __integral_type;
955 typedef __atomic_base<unsigned long long> __base_type;
957 atomic() noexcept = default;
958 ~atomic() noexcept = default;
959 atomic(const atomic&) = delete;
960 atomic& operator=(const atomic&) = delete;
961 atomic& operator=(const atomic&) volatile = delete;
963 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
965 using __base_type::operator __integral_type;
966 using __base_type::operator=;
968#ifdef __cpp_lib_atomic_is_always_lock_free
969 static constexpr bool is_always_lock_free = ATOMIC_LLONG_LOCK_FREE == 2;
975 struct atomic<wchar_t> : __atomic_base<wchar_t>
977 typedef wchar_t __integral_type;
978 typedef __atomic_base<wchar_t> __base_type;
980 atomic() noexcept = default;
981 ~atomic() noexcept = default;
982 atomic(const atomic&) = delete;
983 atomic& operator=(const atomic&) = delete;
984 atomic& operator=(const atomic&) volatile = delete;
986 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
988 using __base_type::operator __integral_type;
989 using __base_type::operator=;
991#ifdef __cpp_lib_atomic_is_always_lock_free
992 static constexpr bool is_always_lock_free = ATOMIC_WCHAR_T_LOCK_FREE == 2;
996#ifdef _GLIBCXX_USE_CHAR8_T
999 struct atomic<char8_t> : __atomic_base<char8_t>
1001 typedef char8_t __integral_type;
1002 typedef __atomic_base<char8_t> __base_type;
1004 atomic() noexcept = default;
1005 ~atomic() noexcept = default;
1006 atomic(const atomic&) = delete;
1007 atomic& operator=(const atomic&) = delete;
1008 atomic& operator=(const atomic&) volatile = delete;
1010 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1012 using __base_type::operator __integral_type;
1013 using __base_type::operator=;
1015#ifdef __cpp_lib_atomic_is_always_lock_free
1016 static constexpr bool is_always_lock_free
1017 = ATOMIC_CHAR8_T_LOCK_FREE == 2;
1024 struct atomic<char16_t> : __atomic_base<char16_t>
1026 typedef char16_t __integral_type;
1027 typedef __atomic_base<char16_t> __base_type;
1029 atomic() noexcept = default;
1030 ~atomic() noexcept = default;
1031 atomic(const atomic&) = delete;
1032 atomic& operator=(const atomic&) = delete;
1033 atomic& operator=(const atomic&) volatile = delete;
1035 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1037 using __base_type::operator __integral_type;
1038 using __base_type::operator=;
1040#ifdef __cpp_lib_atomic_is_always_lock_free
1041 static constexpr bool is_always_lock_free
1042 = ATOMIC_CHAR16_T_LOCK_FREE == 2;
1048 struct atomic<char32_t> : __atomic_base<char32_t>
1050 typedef char32_t __integral_type;
1051 typedef __atomic_base<char32_t> __base_type;
1053 atomic() noexcept = default;
1054 ~atomic() noexcept = default;
1055 atomic(const atomic&) = delete;
1056 atomic& operator=(const atomic&) = delete;
1057 atomic& operator=(const atomic&) volatile = delete;
1059 constexpr atomic(__integral_type __i) noexcept : __base_type(__i) { }
1061 using __base_type::operator __integral_type;
1062 using __base_type::operator=;
1064#ifdef __cpp_lib_atomic_is_always_lock_free
1065 static constexpr bool is_always_lock_free
1066 = ATOMIC_CHAR32_T_LOCK_FREE == 2;
1110#ifdef _GLIBCXX_USE_CHAR8_T
1121#ifdef _GLIBCXX_USE_C99_STDINT
1220 atomic_flag_test_and_set_explicit(
atomic_flag* __a,
1222 {
return __a->test_and_set(__m); }
1225 atomic_flag_test_and_set_explicit(
volatile atomic_flag* __a,
1227 {
return __a->test_and_set(__m); }
1229#if __cpp_lib_atomic_flag_test
1232 {
return __a->test(); }
1235 atomic_flag_test(
const volatile atomic_flag* __a)
noexcept
1236 {
return __a->test(); }
1241 {
return __a->test(__m); }
1244 atomic_flag_test_explicit(
const volatile atomic_flag* __a,
1246 {
return __a->test(__m); }
1251 { __a->clear(__m); }
1254 atomic_flag_clear_explicit(
volatile atomic_flag* __a,
1256 { __a->clear(__m); }
1259 atomic_flag_test_and_set(
atomic_flag* __a)
noexcept
1260 {
return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1263 atomic_flag_test_and_set(
volatile atomic_flag* __a)
noexcept
1264 {
return atomic_flag_test_and_set_explicit(__a, memory_order_seq_cst); }
1268 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1271 atomic_flag_clear(
volatile atomic_flag* __a)
noexcept
1272 { atomic_flag_clear_explicit(__a, memory_order_seq_cst); }
1274#if __cpp_lib_atomic_wait
1276 atomic_flag_wait(
atomic_flag* __a,
bool __old)
noexcept
1277 { __a->wait(__old); }
1280 atomic_flag_wait_explicit(
atomic_flag* __a,
bool __old,
1282 { __a->wait(__old, __m); }
1286 { __a->notify_one(); }
1290 { __a->notify_all(); }
1296 template<
typename _Tp>
1297 using __atomic_val_t = __type_identity_t<_Tp>;
1298 template<
typename _Tp>
1304 template<
typename _ITp>
1307 {
return __a->is_lock_free(); }
1309 template<
typename _ITp>
1311 atomic_is_lock_free(
const volatile atomic<_ITp>* __a)
noexcept
1312 {
return __a->is_lock_free(); }
1314 template<
typename _ITp>
1316 atomic_init(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1317 { __a->store(__i, memory_order_relaxed); }
1319 template<
typename _ITp>
1321 atomic_init(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1322 { __a->store(__i, memory_order_relaxed); }
1324 template<
typename _ITp>
1326 atomic_store_explicit(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1328 { __a->store(__i, __m); }
1330 template<
typename _ITp>
1332 atomic_store_explicit(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1334 { __a->store(__i, __m); }
1336 template<
typename _ITp>
1339 {
return __a->load(__m); }
1341 template<
typename _ITp>
1345 {
return __a->load(__m); }
1347 template<
typename _ITp>
1349 atomic_exchange_explicit(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i,
1351 {
return __a->exchange(__i, __m); }
1353 template<
typename _ITp>
1356 __atomic_val_t<_ITp> __i,
1358 {
return __a->exchange(__i, __m); }
1360 template<
typename _ITp>
1362 atomic_compare_exchange_weak_explicit(
atomic<_ITp>* __a,
1363 __atomic_val_t<_ITp>* __i1,
1364 __atomic_val_t<_ITp> __i2,
1367 {
return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1369 template<
typename _ITp>
1371 atomic_compare_exchange_weak_explicit(
volatile atomic<_ITp>* __a,
1372 __atomic_val_t<_ITp>* __i1,
1373 __atomic_val_t<_ITp> __i2,
1376 {
return __a->compare_exchange_weak(*__i1, __i2, __m1, __m2); }
1378 template<
typename _ITp>
1380 atomic_compare_exchange_strong_explicit(
atomic<_ITp>* __a,
1381 __atomic_val_t<_ITp>* __i1,
1382 __atomic_val_t<_ITp> __i2,
1385 {
return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1387 template<
typename _ITp>
1389 atomic_compare_exchange_strong_explicit(
volatile atomic<_ITp>* __a,
1390 __atomic_val_t<_ITp>* __i1,
1391 __atomic_val_t<_ITp> __i2,
1394 {
return __a->compare_exchange_strong(*__i1, __i2, __m1, __m2); }
1397 template<
typename _ITp>
1399 atomic_store(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1400 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1402 template<
typename _ITp>
1404 atomic_store(
volatile atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1405 { atomic_store_explicit(__a, __i, memory_order_seq_cst); }
1407 template<
typename _ITp>
1410 {
return atomic_load_explicit(__a, memory_order_seq_cst); }
1412 template<
typename _ITp>
1415 {
return atomic_load_explicit(__a, memory_order_seq_cst); }
1417 template<
typename _ITp>
1419 atomic_exchange(
atomic<_ITp>* __a, __atomic_val_t<_ITp> __i)
noexcept
1420 {
return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1422 template<
typename _ITp>
1425 __atomic_val_t<_ITp> __i)
noexcept
1426 {
return atomic_exchange_explicit(__a, __i, memory_order_seq_cst); }
1428 template<
typename _ITp>
1431 __atomic_val_t<_ITp>* __i1,
1432 __atomic_val_t<_ITp> __i2)
noexcept
1434 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1435 memory_order_seq_cst,
1436 memory_order_seq_cst);
1439 template<
typename _ITp>
1441 atomic_compare_exchange_weak(
volatile atomic<_ITp>* __a,
1442 __atomic_val_t<_ITp>* __i1,
1443 __atomic_val_t<_ITp> __i2)
noexcept
1445 return atomic_compare_exchange_weak_explicit(__a, __i1, __i2,
1446 memory_order_seq_cst,
1447 memory_order_seq_cst);
1450 template<
typename _ITp>
1453 __atomic_val_t<_ITp>* __i1,
1454 __atomic_val_t<_ITp> __i2)
noexcept
1456 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1457 memory_order_seq_cst,
1458 memory_order_seq_cst);
1461 template<
typename _ITp>
1463 atomic_compare_exchange_strong(
volatile atomic<_ITp>* __a,
1464 __atomic_val_t<_ITp>* __i1,
1465 __atomic_val_t<_ITp> __i2)
noexcept
1467 return atomic_compare_exchange_strong_explicit(__a, __i1, __i2,
1468 memory_order_seq_cst,
1469 memory_order_seq_cst);
1473#if __cpp_lib_atomic_wait
1474 template<
typename _Tp>
1477 typename std::atomic<_Tp>::value_type __old)
noexcept
1478 { __a->wait(__old); }
1480 template<
typename _Tp>
1483 typename std::atomic<_Tp>::value_type __old,
1485 { __a->wait(__old, __m); }
1487 template<
typename _Tp>
1490 { __a->notify_one(); }
1492 template<
typename _Tp>
1495 { __a->notify_all(); }
1502 template<
typename _ITp>
1505 __atomic_diff_t<_ITp> __i,
1507 {
return __a->fetch_add(__i, __m); }
1509 template<
typename _ITp>
1512 __atomic_diff_t<_ITp> __i,
1514 {
return __a->fetch_add(__i, __m); }
1516 template<
typename _ITp>
1519 __atomic_diff_t<_ITp> __i,
1521 {
return __a->fetch_sub(__i, __m); }
1523 template<
typename _ITp>
1526 __atomic_diff_t<_ITp> __i,
1528 {
return __a->fetch_sub(__i, __m); }
1530 template<
typename _ITp>
1532 atomic_fetch_and_explicit(__atomic_base<_ITp>* __a,
1533 __atomic_val_t<_ITp> __i,
1535 {
return __a->fetch_and(__i, __m); }
1537 template<
typename _ITp>
1539 atomic_fetch_and_explicit(
volatile __atomic_base<_ITp>* __a,
1540 __atomic_val_t<_ITp> __i,
1542 {
return __a->fetch_and(__i, __m); }
1544 template<
typename _ITp>
1546 atomic_fetch_or_explicit(__atomic_base<_ITp>* __a,
1547 __atomic_val_t<_ITp> __i,
1549 {
return __a->fetch_or(__i, __m); }
1551 template<
typename _ITp>
1553 atomic_fetch_or_explicit(
volatile __atomic_base<_ITp>* __a,
1554 __atomic_val_t<_ITp> __i,
1556 {
return __a->fetch_or(__i, __m); }
1558 template<
typename _ITp>
1560 atomic_fetch_xor_explicit(__atomic_base<_ITp>* __a,
1561 __atomic_val_t<_ITp> __i,
1563 {
return __a->fetch_xor(__i, __m); }
1565 template<
typename _ITp>
1567 atomic_fetch_xor_explicit(
volatile __atomic_base<_ITp>* __a,
1568 __atomic_val_t<_ITp> __i,
1570 {
return __a->fetch_xor(__i, __m); }
1572 template<
typename _ITp>
1575 __atomic_diff_t<_ITp> __i)
noexcept
1576 {
return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1578 template<
typename _ITp>
1581 __atomic_diff_t<_ITp> __i)
noexcept
1582 {
return atomic_fetch_add_explicit(__a, __i, memory_order_seq_cst); }
1584 template<
typename _ITp>
1587 __atomic_diff_t<_ITp> __i)
noexcept
1588 {
return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1590 template<
typename _ITp>
1593 __atomic_diff_t<_ITp> __i)
noexcept
1594 {
return atomic_fetch_sub_explicit(__a, __i, memory_order_seq_cst); }
1596 template<
typename _ITp>
1598 atomic_fetch_and(__atomic_base<_ITp>* __a,
1599 __atomic_val_t<_ITp> __i)
noexcept
1600 {
return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1602 template<
typename _ITp>
1604 atomic_fetch_and(
volatile __atomic_base<_ITp>* __a,
1605 __atomic_val_t<_ITp> __i)
noexcept
1606 {
return atomic_fetch_and_explicit(__a, __i, memory_order_seq_cst); }
1608 template<
typename _ITp>
1610 atomic_fetch_or(__atomic_base<_ITp>* __a,
1611 __atomic_val_t<_ITp> __i)
noexcept
1612 {
return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1614 template<
typename _ITp>
1616 atomic_fetch_or(
volatile __atomic_base<_ITp>* __a,
1617 __atomic_val_t<_ITp> __i)
noexcept
1618 {
return atomic_fetch_or_explicit(__a, __i, memory_order_seq_cst); }
1620 template<
typename _ITp>
1622 atomic_fetch_xor(__atomic_base<_ITp>* __a,
1623 __atomic_val_t<_ITp> __i)
noexcept
1624 {
return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1626 template<
typename _ITp>
1628 atomic_fetch_xor(
volatile __atomic_base<_ITp>* __a,
1629 __atomic_val_t<_ITp> __i)
noexcept
1630 {
return atomic_fetch_xor_explicit(__a, __i, memory_order_seq_cst); }
1632#ifdef __cpp_lib_atomic_float
1634 struct atomic<float> : __atomic_float<float>
1636 atomic() noexcept = default;
1639 atomic(
float __fp) noexcept : __atomic_float<
float>(__fp)
1642 atomic& operator=(
const atomic&)
volatile =
delete;
1643 atomic& operator=(
const atomic&) =
delete;
1645 using __atomic_float<
float>::operator=;
1649 struct atomic<double> : __atomic_float<double>
1651 atomic() noexcept = default;
1654 atomic(
double __fp) noexcept : __atomic_float<
double>(__fp)
1657 atomic& operator=(
const atomic&)
volatile =
delete;
1658 atomic& operator=(
const atomic&) =
delete;
1660 using __atomic_float<
double>::operator=;
1664 struct atomic<long double> : __atomic_float<long double>
1666 atomic() noexcept = default;
1669 atomic(
long double __fp) noexcept : __atomic_float<
long double>(__fp)
1672 atomic& operator=(
const atomic&)
volatile =
delete;
1673 atomic& operator=(
const atomic&) =
delete;
1675 using __atomic_float<
long double>::operator=;
1678#ifdef __STDCPP_FLOAT16_T__
1680 struct atomic<_Float16> : __atomic_float<_Float16>
1682 atomic() noexcept = default;
1685 atomic(_Float16 __fp) noexcept : __atomic_float<_Float16>(__fp)
1688 atomic& operator=(
const atomic&)
volatile =
delete;
1689 atomic& operator=(
const atomic&) =
delete;
1691 using __atomic_float<_Float16>::operator=;
1695#ifdef __STDCPP_FLOAT32_T__
1697 struct atomic<_Float32> : __atomic_float<_Float32>
1699 atomic() noexcept = default;
1702 atomic(_Float32 __fp) noexcept : __atomic_float<_Float32>(__fp)
1705 atomic& operator=(
const atomic&)
volatile =
delete;
1706 atomic& operator=(
const atomic&) =
delete;
1708 using __atomic_float<_Float32>::operator=;
1712#ifdef __STDCPP_FLOAT64_T__
1714 struct atomic<_Float64> : __atomic_float<_Float64>
1716 atomic() noexcept = default;
1719 atomic(_Float64 __fp) noexcept : __atomic_float<_Float64>(__fp)
1722 atomic& operator=(
const atomic&)
volatile =
delete;
1723 atomic& operator=(
const atomic&) =
delete;
1725 using __atomic_float<_Float64>::operator=;
1729#ifdef __STDCPP_FLOAT128_T__
1731 struct atomic<_Float128> : __atomic_float<_Float128>
1733 atomic() noexcept = default;
1736 atomic(_Float128 __fp) noexcept : __atomic_float<_Float128>(__fp)
1739 atomic& operator=(
const atomic&)
volatile =
delete;
1740 atomic& operator=(
const atomic&) =
delete;
1742 using __atomic_float<_Float128>::operator=;
1746#ifdef __STDCPP_BFLOAT16_T__
1748 struct atomic<__gnu_cxx::__bfloat16_t> : __atomic_float<__gnu_cxx::__bfloat16_t>
1750 atomic() noexcept = default;
1753 atomic(__gnu_cxx::__bfloat16_t __fp) noexcept : __atomic_float<__gnu_cxx::__bfloat16_t>(__fp)
1756 atomic& operator=(
const atomic&)
volatile =
delete;
1757 atomic& operator=(
const atomic&) =
delete;
1759 using __atomic_float<__gnu_cxx::__bfloat16_t>::operator=;
1764#ifdef __cpp_lib_atomic_ref
1766 template<
typename _Tp>
1767 struct atomic_ref : __atomic_ref<_Tp>
1770 atomic_ref(_Tp& __t) noexcept : __atomic_ref<_Tp>(__t)
1773 atomic_ref& operator=(
const atomic_ref&) =
delete;
1775 atomic_ref(
const atomic_ref&) =
default;
1777 using __atomic_ref<_Tp>::operator=;
1781#ifdef __cpp_lib_atomic_lock_free_type_aliases
1782# ifdef _GLIBCXX_HAVE_PLATFORM_WAIT
1783 using atomic_signed_lock_free
1785 using atomic_unsigned_lock_free
1787# elif ATOMIC_INT_LOCK_FREE == 2
1790# elif ATOMIC_LONG_LOCK_FREE == 2
1793# elif ATOMIC_CHAR_LOCK_FREE == 2
1797# error "libstdc++ bug: no lock-free atomics but they were emitted in <version>"
1803_GLIBCXX_END_NAMESPACE_VERSION
constexpr _Tp * __addressof(_Tp &__r) noexcept
Same as C++11 std::addressof.
atomic< unsigned long > atomic_ulong
atomic_ulong
atomic< intmax_t > atomic_intmax_t
atomic_intmax_t
atomic< uintptr_t > atomic_uintptr_t
atomic_uintptr_t
atomic< signed char > atomic_schar
atomic_schar
atomic< int_least8_t > atomic_int_least8_t
atomic_int_least8_t
atomic< unsigned long long > atomic_ullong
atomic_ullong
atomic< uint_fast8_t > atomic_uint_fast8_t
atomic_uint_fast8_t
atomic< intptr_t > atomic_intptr_t
atomic_intptr_t
atomic< int16_t > atomic_int16_t
atomic_int16_t
atomic< size_t > atomic_size_t
atomic_size_t
atomic< long > atomic_long
atomic_long
atomic< uint_least8_t > atomic_uint_least8_t
atomic_uint_least8_t
atomic< short > atomic_short
atomic_short
atomic< uint_least16_t > atomic_uint_least16_t
atomic_uint_least16_t
atomic< uint16_t > atomic_uint16_t
atomic_uint16_t
atomic< uint64_t > atomic_uint64_t
atomic_uint64_t
atomic< int_least32_t > atomic_int_least32_t
atomic_int_least32_t
atomic< uint8_t > atomic_uint8_t
atomic_uint8_t
#define ATOMIC_BOOL_LOCK_FREE
atomic< wchar_t > atomic_wchar_t
atomic_wchar_t
atomic< unsigned int > atomic_uint
atomic_uint
atomic< uint_least32_t > atomic_uint_least32_t
atomic_uint_least32_t
atomic< uint_fast64_t > atomic_uint_fast64_t
atomic_uint_fast64_t
atomic< int_fast32_t > atomic_int_fast32_t
atomic_int_fast32_t
atomic< char > atomic_char
atomic_char
atomic< int > atomic_int
atomic_int
atomic< uint_least64_t > atomic_uint_least64_t
atomic_uint_least64_t
atomic< int64_t > atomic_int64_t
atomic_int64_t
atomic< uintmax_t > atomic_uintmax_t
atomic_uintmax_t
atomic< int_fast16_t > atomic_int_fast16_t
atomic_int_fast16_t
atomic< int32_t > atomic_int32_t
atomic_int32_t
atomic< uint_fast16_t > atomic_uint_fast16_t
atomic_uint_fast16_t
atomic< int8_t > atomic_int8_t
atomic_int8_t
atomic< long long > atomic_llong
atomic_llong
atomic< char16_t > atomic_char16_t
atomic_char16_t
atomic< int_fast64_t > atomic_int_fast64_t
atomic_int_fast64_t
atomic< ptrdiff_t > atomic_ptrdiff_t
atomic_ptrdiff_t
atomic< char32_t > atomic_char32_t
atomic_char32_t
atomic< int_least16_t > atomic_int_least16_t
atomic_int_least16_t
atomic< unsigned char > atomic_uchar
atomic_uchar
atomic< int_fast8_t > atomic_int_fast8_t
atomic_int_fast8_t
memory_order
Enumeration for memory_order.
atomic< unsigned short > atomic_ushort
atomic_ushort
atomic< int_least64_t > atomic_int_least64_t
atomic_int_least64_t
atomic< bool > atomic_bool
atomic_bool
atomic< uint_fast32_t > atomic_uint_fast32_t
atomic_uint_fast32_t
atomic< uint32_t > atomic_uint32_t
atomic_uint32_t
ISO C++ entities toplevel namespace is std.
Generic atomic type, primary class template.