Skip to content

Commit afc69a6

Browse files
committed
fix C++20 compatibility (no static constexpr local variables)
1 parent 7193d84 commit afc69a6

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/core/include/mp-units/bits/sudo_cast.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,8 @@ template<QuantityPoint ToQP, typename FwdFromQP, QuantityPoint FromQP = std::rem
161161
using multiplier_type = typename type_traits::multiplier_type;
162162
using value_traits = conversion_value_traits<c_mag, multiplier_type>;
163163

164-
static constexpr auto output_unit_ref = make_reference(FromQP::quantity_spec, ToQP::unit);
165-
static constexpr auto offset_represented_as = [](auto quantity) {
164+
constexpr auto output_unit_ref = make_reference(FromQP::quantity_spec, ToQP::unit);
165+
constexpr auto offset_represented_as = [](auto quantity) {
166166
using Q = decltype(quantity);
167167
// in the following, we take the detour through `quantity_point` to determine the offset between the two
168168
// point_origins; there seem to be cases where we have two `zeroeth_point_origins` of different units (i.e. m vs.
@@ -181,7 +181,7 @@ template<QuantityPoint ToQP, typename FwdFromQP, QuantityPoint FromQP = std::rem
181181
// no scaling of the unit is needed; thus we can perform all computation in a single unit without any runtime
182182
// scaling anywhere
183183
// we statically convert the offset to unit of the quantities, to avoid runtime rescaling.
184-
static constexpr auto offset = offset_represented_as(quantity<FromQP::reference, c_rep_type>{});
184+
constexpr auto offset = offset_represented_as(quantity<FromQP::reference, c_rep_type>{});
185185
return quantity_point{
186186
sudo_cast<typename ToQP::quantity_type>(std::forward<FromQP>(qp).quantity_from(FromQP::point_origin) + offset),
187187
ToQP::point_origin};
@@ -190,7 +190,7 @@ template<QuantityPoint ToQP, typename FwdFromQP, QuantityPoint FromQP = std::rem
190190
// (typically, when at least one of input or output representations is floating-point).
191191
// with those, the choice of unit has almost no impact on the conversion accuracy, and thus we can choose
192192
// the larger unit of the two (input/output) to ensure there is no risk of overflow.
193-
static constexpr auto intermediate_reference = []() {
193+
constexpr auto intermediate_reference = []() {
194194
if constexpr (value_traits::num_mult * value_traits::irr_mult >= value_traits::den_mult) {
195195
// the input unit is larger
196196
return FromQP::reference;
@@ -200,7 +200,7 @@ template<QuantityPoint ToQP, typename FwdFromQP, QuantityPoint FromQP = std::rem
200200
}();
201201
using intermediate_rep_type = typename type_traits::c_type;
202202
using intermediate_quantity_type = quantity<intermediate_reference, intermediate_rep_type>;
203-
static constexpr auto offset = offset_represented_as(intermediate_quantity_type{});
203+
constexpr auto offset = offset_represented_as(intermediate_quantity_type{});
204204
return quantity_point{
205205
sudo_cast<typename ToQP::quantity_type>(
206206
sudo_cast<intermediate_quantity_type>(std::forward<FromQP>(qp).quantity_from(FromQP::point_origin)) + offset),
@@ -212,7 +212,7 @@ template<QuantityPoint ToQP, typename FwdFromQP, QuantityPoint FromQP = std::rem
212212
// that the offset is specified in terms of a larger unit (because otherwise, the offset would overflow too).
213213
// Therefore, we use the offset's unit as intermediate unit if the offset falls outside of the range of the
214214
// smaller unit.
215-
static constexpr auto intermediate_reference = []() {
215+
constexpr auto intermediate_reference = []() {
216216
if constexpr (value_traits::num_mult * value_traits::irr_mult >= value_traits::den_mult) {
217217
// the output unit is smaller; check if we can represent the offset faithfully in the output unit without
218218
// overflow
@@ -234,7 +234,7 @@ template<QuantityPoint ToQP, typename FwdFromQP, QuantityPoint FromQP = std::rem
234234
}();
235235
using intermediate_rep_type = typename type_traits::c_type;
236236
using intermediate_quantity_type = quantity<intermediate_reference, intermediate_rep_type>;
237-
static constexpr auto offset = offset_represented_as(intermediate_quantity_type{});
237+
constexpr auto offset = offset_represented_as(intermediate_quantity_type{});
238238
return quantity_point{
239239
sudo_cast<typename ToQP::quantity_type>(
240240
sudo_cast<intermediate_quantity_type>(std::forward<FromQP>(qp).quantity_from(FromQP::point_origin)) + offset),

0 commit comments

Comments
 (0)