diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index 335f22dd6..aa5eb7256 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -42,7 +42,7 @@ import mp_units.core; template) auto Min, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to) 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) auto Min, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to) auto Max> diff --git a/src/core/include/mp-units/bits/hacks.h b/src/core/include/mp-units/bits/hacks.h index 5030debb7..6dbba51bf 100644 --- a/src/core/include/mp-units/bits/hacks.h +++ b/src/core/include/mp-units/bits/hacks.h @@ -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 diff --git a/src/core/include/mp-units/bits/text_tools.h b/src/core/include/mp-units/bits/text_tools.h index dc5bfed3f..0b1fa7f71 100644 --- a/src/core/include/mp-units/bits/text_tools.h +++ b/src/core/include/mp-units/bits/text_tools.h @@ -43,25 +43,25 @@ template 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", "-"); diff --git a/src/core/include/mp-units/framework/expression_template.h b/src/core/include/mp-units/framework/expression_template.h index 51522f58b..fe64b2277 100644 --- a/src/core/include/mp-units/framework/expression_template.h +++ b/src/core/include/mp-units/framework/expression_template.h @@ -72,7 +72,7 @@ template constexpr bool valid_ratio = false; template<> -constexpr bool valid_ratio<0, 0> = false; +MP_UNITS_INLINE constexpr bool valid_ratio<0, 0> = false; template constexpr bool positive_ratio = gt_zero; @@ -84,7 +84,7 @@ template constexpr bool ratio_one = false; template<> -constexpr bool ratio_one<1> = true; +MP_UNITS_INLINE constexpr bool ratio_one<1> = true; template constexpr bool ratio_one = true; diff --git a/src/core/include/mp-units/framework/unit.h b/src/core/include/mp-units/framework/unit.h index 269ef4d03..bc4fd7e02 100644 --- a/src/core/include/mp-units/framework/unit.h +++ b/src/core/include/mp-units/framework/unit.h @@ -678,11 +678,11 @@ template constexpr bool space_before_unit_symbol = true; template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; // get_unit_symbol diff --git a/src/systems/include/mp-units/systems/angular/units.h b/src/systems/include/mp-units/systems/angular/units.h index a8e6e01d6..25709fd95 100644 --- a/src/systems/include/mp-units/systems/angular/units.h +++ b/src/systems/include/mp-units/systems/angular/units.h @@ -62,8 +62,8 @@ inline constexpr auto deg2 = square(degree); } // namespace angular template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; } // namespace mp_units diff --git a/src/systems/include/mp-units/systems/si/units.h b/src/systems/include/mp-units/systems/si/units.h index 856808784..af14f2df4 100644 --- a/src/systems/include/mp-units/systems/si/units.h +++ b/src/systems/include/mp-units/systems/si/units.h @@ -126,10 +126,10 @@ using namespace non_si; } // namespace si template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; template<> -constexpr bool space_before_unit_symbol = false; +MP_UNITS_INLINE constexpr bool space_before_unit_symbol = false; } // namespace mp_units