33
44#include < array>
55#include < atomic>
6- #include < memory>
76#include < type_traits>
87
9- #include " ../Box.hpp"
108#include " ../NamedTuple.hpp"
11- #include " ../Ref.hpp"
129#include " ../Tuple.hpp"
1310#include " ../named_tuple_t.hpp"
1411#include " ../to_view.hpp"
@@ -34,6 +31,19 @@ struct is_atomic<std::atomic<T>> {
3431 };
3532};
3633
34+ template <>
35+ struct is_atomic <std::atomic_flag> {
36+ static constexpr bool value = true ;
37+ using RemoveAtomicT = bool ;
38+ static void set (RemoveAtomicT&& val, std::atomic_flag* _t) {
39+ if (val) {
40+ _t->test_and_set (std::memory_order_relaxed);
41+ } else {
42+ _t->clear (std::memory_order_relaxed);
43+ }
44+ }
45+ };
46+
3747template <class T , size_t N>
3848struct is_atomic <std::array<T, N>> {
3949 using Type = std::remove_cvref_t <T>;
@@ -58,7 +68,7 @@ struct is_atomic<T[N]> {
5868 static void set (RemoveAtomicT&& val, T (*_t)[N]) {
5969 for (size_t i = 0 ; i < N; ++i) {
6070 is_atomic<T>::set (
61- std::forward<typename is_atomic<T >::RemoveAtomicT>(val[i]),
71+ std::forward<typename is_atomic<Type >::RemoveAtomicT>(val[i]),
6272 &((*_t)[i]));
6373 }
6474 }
@@ -75,16 +85,16 @@ struct is_atomic<NamedTuple<Fields...>> {
7585
7686 static void set (RemoveAtomicT&& val, NamedTuple<Fields...>* _t) {
7787 (is_atomic<typename Fields::Type>::set (
78- std::forward<typename is_atomic<typename Fields::Type>::RemoveAtomicT>(
88+ std::forward<typename is_atomic<
89+ std::remove_cvref_t <typename Fields::Type>>::RemoveAtomicT>(
7990 val.template get <Fields::name_>()),
8091 &(_t->template get <Fields::name_>())),
8192 ...);
8293 }
8394};
8495
8596template <class T >
86- requires (std::is_class_v<T> && std::is_aggregate_v<T> &&
87- !std::is_move_constructible_v<T>)
97+ requires (std::is_class_v<T> && std::is_aggregate_v<T>)
8898struct is_atomic <T> {
8999 static constexpr bool value = is_atomic<named_tuple_t <T>>::value;
90100
0 commit comments