@@ -63,6 +63,16 @@ inline array_ptr_variant_t get_typed_ptr(bsp_array_t array) {
63
63
return {};
64
64
}
65
65
66
+ template <typename T>
67
+ constexpr static bool is_c_complex_v =
68
+ std::is_same_v<std::remove_cvref_t <T>, _Complex double > ||
69
+ std::is_same_v<std::remove_cvref_t <T>, _Complex float >;
70
+
71
+ template <typename T, typename U>
72
+ constexpr static bool mixed_c_complex_v =
73
+ (is_c_complex_v<T> && !is_c_complex_v<U>) ||
74
+ (!is_c_complex_v<T> && is_c_complex_v<U>);
75
+
66
76
} // namespace __detail
67
77
68
78
} // namespace binsparse
@@ -76,7 +86,8 @@ inline void bsp_array_read(bsp_array_t array, size_t index, T& value) {
76
86
[&](auto * ptr) {
77
87
using U = std::remove_pointer_t <decltype (ptr)>;
78
88
79
- if constexpr (std::is_assignable_v<T&, U>) {
89
+ if constexpr (std::is_convertible_v<U, T> &&
90
+ !binsparse::__detail::mixed_c_complex_v<T, U>) {
80
91
value = ptr[index];
81
92
}
82
93
},
@@ -92,7 +103,8 @@ inline void bsp_array_write(bsp_array_t array, size_t index, U value) {
92
103
[&](auto * ptr) {
93
104
using T = std::remove_pointer_t <decltype (ptr)>;
94
105
95
- if constexpr (std::is_assignable_v<T&, U>) {
106
+ if constexpr (std::is_convertible_v<U, T> &&
107
+ !binsparse::__detail::mixed_c_complex_v<T, U>) {
96
108
ptr[index] = value;
97
109
}
98
110
},
@@ -110,7 +122,8 @@ inline void bsp_array_awrite(bsp_array_t array_0, size_t index_0,
110
122
using T = std::remove_pointer_t <decltype (ptr_0)>;
111
123
using U = std::remove_pointer_t <decltype (ptr_1)>;
112
124
113
- if constexpr (std::is_assignable_v<T&, U>) {
125
+ if constexpr (std::is_convertible_v<U, T> &&
126
+ !binsparse::__detail::mixed_c_complex_v<T, U>) {
114
127
ptr_0[index_0] = ptr_1[index_1];
115
128
}
116
129
},
0 commit comments