33#define __BITFILLED_BASE_OPS_HPP__
44
55#include " bitfilled/access.hpp"
6+ #include " bitfilled/macros.hpp"
67#include " bitfilled/size.hpp"
78
89namespace bitfilled
@@ -17,6 +18,14 @@ namespace bitfilled
1718#define BITFILLED_ASSIGN_RETURN_EXPR (EXPR )
1819#endif
1920
21+ #if _MSC_VER
22+ #define BITFILLED_FIELD_PROPS_PARAM_T T
23+ #define BITFILLED_FIELDSET_PROPS_PARAM_T T
24+ #else
25+ #define BITFILLED_FIELD_PROPS_PARAM_T bitfield_props<FIRST_BIT , LAST_BIT >
26+ #define BITFILLED_FIELDSET_PROPS_PARAM_T regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >
27+ #endif
28+
2029// / @brief copy const-volatile qualifiers from one reference type to another
2130// https://stackoverflow.com/a/31173086
2231template <typename T, typename U>
@@ -156,99 +165,106 @@ struct base
156165
157166 public:
158167 template <std::size_t FIRST_BIT , std::size_t LAST_BIT , typename TVal>
159- static void set_field (bitfield_props< FIRST_BIT , LAST_BIT > & bf, TVal value)
168+ static void set_field (BITFILLED_FIELD_PROPS_PARAM_T & bf, TVal value)
160169 requires(is_writeable<bitfield_ops::access()>)
161170 {
162171 const auto v = static_cast <int_type>(value);
163172 if constexpr (!is_readable<bitfield_ops::access ()> or
164173 is_ephemeralwrite<bitfield_ops::access ()>)
165174 {
166- setter (bf, bf. position_field (v));
175+ setter (bf, bitfield_props< FIRST_BIT , LAST_BIT >:: position_field (v));
167176 }
168177 else
169178 {
170- setter (bf, bf. insert_field (getter (bf), v));
179+ setter (bf, bitfield_props< FIRST_BIT , LAST_BIT >:: insert_field (getter (bf), v));
171180 }
172181 }
173182 template <std::size_t FIRST_BIT , std::size_t LAST_BIT , typename TVal>
174- static void set_field (volatile bitfield_props< FIRST_BIT , LAST_BIT > & bf, TVal value)
183+ static void set_field (volatile BITFILLED_FIELD_PROPS_PARAM_T & bf, TVal value)
175184 requires(is_writeable<bitfield_ops::access()>)
176185 {
177186 const auto v = static_cast <int_type>(value);
178187 if constexpr (!is_readable<bitfield_ops::access ()> or
179188 is_ephemeralwrite<bitfield_ops::access ()>)
180189 {
181- setter (bf, bf. position_field (v));
190+ setter (bf, bitfield_props< FIRST_BIT , LAST_BIT >:: position_field (v));
182191 }
183192 else
184193 {
185- setter (bf, bf. insert_field (getter (bf), v));
194+ setter (bf, bitfield_props< FIRST_BIT , LAST_BIT >:: insert_field (getter (bf), v));
186195 }
187196 }
188197
189198 template <typename TVal, std::size_t FIRST_BIT , std::size_t LAST_BIT >
190- static TVal get_field (const bitfield_props< FIRST_BIT , LAST_BIT > & bf)
199+ static TVal get_field (const BITFILLED_FIELD_PROPS_PARAM_T & bf)
191200 requires(is_readable<bitfield_ops::access()>)
192201 {
193- auto x = static_cast <TVal>(bf.extract_field (getter (bf)));
194- return bf.sign_extend (x);
202+ auto x =
203+ static_cast <TVal>(bitfield_props<FIRST_BIT , LAST_BIT >::extract_field (getter (bf)));
204+ return bitfield_props<FIRST_BIT , LAST_BIT >::sign_extend (x);
195205 }
196206 template <typename TVal, std::size_t FIRST_BIT , std::size_t LAST_BIT >
197- static TVal get_field (const volatile bitfield_props< FIRST_BIT , LAST_BIT > & bf)
207+ static TVal get_field (const volatile BITFILLED_FIELD_PROPS_PARAM_T & bf)
198208 requires(is_readable<bitfield_ops::access()>)
199209 {
200- auto x = static_cast <TVal>(bf.extract_field (getter (bf)));
201- return bf.sign_extend (x);
210+ auto x =
211+ static_cast <TVal>(bitfield_props<FIRST_BIT , LAST_BIT >::extract_field (getter (bf)));
212+ return bitfield_props<FIRST_BIT , LAST_BIT >::sign_extend (x);
202213 }
203214
204215 template <std::size_t ITEM_SIZE , std::size_t ITEM_COUNT , std::size_t OFFSET , typename TVal>
205- static void set_item (regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >& bf,
206- std::size_t index, TVal value)
216+ static void set_item (BITFILLED_FIELDSET_PROPS_PARAM_T & bf, std::size_t index, TVal value)
207217 requires(is_writeable<bitfield_ops::access()>)
208218 {
209219 const auto v = static_cast <int_type>(value);
210220 if constexpr (!is_readable<bitfield_ops::access ()> or
211221 is_ephemeralwrite<bitfield_ops::access ()>)
212222 {
213- setter (bf, bf.position_field (v, index));
223+ setter (bf, regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::position_field (
224+ v, index));
214225 }
215226 else
216227 {
217- setter (bf, bf.insert_field (getter (bf), v, index));
228+ setter (bf, regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::insert_field (
229+ getter (bf), v, index));
218230 }
219231 }
220232 template <std::size_t ITEM_SIZE , std::size_t ITEM_COUNT , std::size_t OFFSET , typename TVal>
221- static void set_item (volatile regbitfieldset_props< ITEM_SIZE , ITEM_COUNT , OFFSET >& bf ,
222- std:: size_t index, TVal value)
233+ static void set_item (volatile BITFILLED_FIELDSET_PROPS_PARAM_T & bf, std:: size_t index ,
234+ TVal value)
223235 requires(is_writeable<bitfield_ops::access()>)
224236 {
225237 const auto v = static_cast <int_type>(value);
226238 if constexpr (!is_readable<bitfield_ops::access ()> or
227239 is_ephemeralwrite<bitfield_ops::access ()>)
228240 {
229- setter (bf, bf.position_field (v, index));
241+ setter (bf, regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::position_field (
242+ v, index));
230243 }
231244 else
232245 {
233- setter (bf, bf.insert_field (getter (bf), v, index));
246+ setter (bf, regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::insert_field (
247+ getter (bf), v, index));
234248 }
235249 }
236250
237251 template <typename TVal, std::size_t ITEM_SIZE , std::size_t ITEM_COUNT , std::size_t OFFSET >
238- static TVal get_item (const regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >& bf,
239- std::size_t index)
252+ static TVal get_item (const BITFILLED_FIELDSET_PROPS_PARAM_T & bf, std::size_t index)
240253 requires(is_readable<bitfield_ops::access()>)
241254 {
242- auto x = static_cast <TVal>(bf.extract_field (getter (bf), index));
243- return bf.sign_extend (x);
255+ auto x = static_cast <TVal>(
256+ regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::extract_field (getter (bf),
257+ index));
258+ return regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::sign_extend (x);
244259 }
245260 template <typename TVal, std::size_t ITEM_SIZE , std::size_t ITEM_COUNT , std::size_t OFFSET >
246- static TVal get_item (const volatile regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >& bf,
247- std::size_t index)
261+ static TVal get_item (const volatile BITFILLED_FIELDSET_PROPS_PARAM_T & bf, std::size_t index)
248262 requires(is_readable<bitfield_ops::access()>)
249263 {
250- auto x = static_cast <TVal>(bf.extract_field (getter (bf), index));
251- return bf.sign_extend (x);
264+ auto x = static_cast <TVal>(
265+ regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::extract_field (getter (bf),
266+ index));
267+ return regbitfieldset_props<ITEM_SIZE , ITEM_COUNT , OFFSET >::sign_extend (x);
252268 }
253269 };
254270};
0 commit comments