fix: workarounds for not-working CWG2387

This commit is contained in:
Mateusz Pusz
2024-09-05 22:05:35 +02:00
parent 45013f6752
commit 7eb9b764bd
7 changed files with 24 additions and 21 deletions

View File

@@ -42,7 +42,7 @@ import mp_units.core;
template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>
constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; };
MP_UNITS_INLINE constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; };
template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>

View File

@@ -77,6 +77,9 @@
#define MP_UNITS_HOSTED __STDC_HOSTED__
#endif
// workarounds for https://cplusplus.github.io/CWG/issues/2387.html
#define MP_UNITS_INLINE inline
#if MP_UNITS_COMP_MSVC
#define MP_UNITS_TYPENAME typename

View File

@@ -43,25 +43,25 @@ template<std::intmax_t Value>
constexpr basic_fixed_string superscript_number = u8"";
template<>
constexpr basic_fixed_string superscript_number<0> = u8"\u2070";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<0> = u8"\u2070";
template<>
constexpr basic_fixed_string superscript_number<1> = u8"\u00b9";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<1> = u8"\u00b9";
template<>
constexpr basic_fixed_string superscript_number<2> = u8"\u00b2";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<2> = u8"\u00b2";
template<>
constexpr basic_fixed_string superscript_number<3> = u8"\u00b3";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<3> = u8"\u00b3";
template<>
constexpr basic_fixed_string superscript_number<4> = u8"\u2074";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<4> = u8"\u2074";
template<>
constexpr basic_fixed_string superscript_number<5> = u8"\u2075";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<5> = u8"\u2075";
template<>
constexpr basic_fixed_string superscript_number<6> = u8"\u2076";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<6> = u8"\u2076";
template<>
constexpr basic_fixed_string superscript_number<7> = u8"\u2077";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<7> = u8"\u2077";
template<>
constexpr basic_fixed_string superscript_number<8> = u8"\u2078";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<8> = u8"\u2078";
template<>
constexpr basic_fixed_string superscript_number<9> = u8"\u2079";
MP_UNITS_INLINE constexpr basic_fixed_string superscript_number<9> = u8"\u2079";
inline constexpr symbol_text superscript_minus(u8"\u207b", "-");

View File

@@ -72,7 +72,7 @@ template<int Num>
constexpr bool valid_ratio<Num, 0> = false;
template<>
constexpr bool valid_ratio<0, 0> = false;
MP_UNITS_INLINE constexpr bool valid_ratio<0, 0> = false;
template<int Num, int... Den>
constexpr bool positive_ratio = gt_zero<Num>;
@@ -84,7 +84,7 @@ template<int Num, int... Den>
constexpr bool ratio_one = false;
template<>
constexpr bool ratio_one<1> = true;
MP_UNITS_INLINE constexpr bool ratio_one<1> = true;
template<int N>
constexpr bool ratio_one<N, N> = true;

View File

@@ -678,11 +678,11 @@ template<Unit auto U>
constexpr bool space_before_unit_symbol = true;
template<>
constexpr bool space_before_unit_symbol<one> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<one> = false;
template<>
constexpr bool space_before_unit_symbol<percent> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<percent> = false;
template<>
constexpr bool space_before_unit_symbol<per_mille> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<per_mille> = false;
// get_unit_symbol

View File

@@ -62,8 +62,8 @@ inline constexpr auto deg2 = square(degree);
} // namespace angular
template<>
constexpr bool space_before_unit_symbol<angular::degree> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<angular::degree> = false;
template<>
constexpr bool space_before_unit_symbol<angular::gradian> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<angular::gradian> = false;
} // namespace mp_units

View File

@@ -126,10 +126,10 @@ using namespace non_si;
} // namespace si
template<>
constexpr bool space_before_unit_symbol<non_si::degree> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<non_si::degree> = false;
template<>
constexpr bool space_before_unit_symbol<non_si::arcminute> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<non_si::arcminute> = false;
template<>
constexpr bool space_before_unit_symbol<non_si::arcsecond> = false;
MP_UNITS_INLINE constexpr bool space_before_unit_symbol<non_si::arcsecond> = false;
} // namespace mp_units