diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index 2aebf72b..6b0448f1 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -28,13 +28,16 @@ #include #include -template auto Min, std::convertible_to auto Max> +template) auto Min, + UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to) auto Max> inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; }; -template auto Min, std::convertible_to auto Max> +template) auto Min, + UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to) auto Max> using is_in_range_t = decltype(is_in_range); -template auto Min, std::convertible_to auto Max> +template) auto Min, + UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to) auto Max> class ranged_representation : public validated_type> { public: using validated_type>::validated_type; diff --git a/src/core/include/units/base_dimension.h b/src/core/include/units/base_dimension.h index 0af40adb..5f1d3f48 100644 --- a/src/core/include/units/base_dimension.h +++ b/src/core/include/units/base_dimension.h @@ -54,7 +54,7 @@ template struct base_dimension { static constexpr auto symbol = Symbol; ///< Unique base dimension identifier using base_unit = U; ///< Base unit adopted for this dimension - static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = magnitude{}; + static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = magnitude{}; }; // base_dimension_less diff --git a/src/core/include/units/bits/common_type.h b/src/core/include/units/bits/common_type.h index 8955d5ab..2b674adb 100644 --- a/src/core/include/units/bits/common_type.h +++ b/src/core/include/units/bits/common_type.h @@ -66,8 +66,8 @@ struct common_quantity_reference_impl, reference> { template struct common_quantity_reference_impl, reference> { - static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = common_magnitude(reference::mag, - reference::mag); + static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = common_magnitude(reference::mag, + reference::mag); using dimension = conditional, D2, D1>; using unit = downcast_unit; using type = reference; diff --git a/src/core/include/units/bits/external/hacks.h b/src/core/include/units/bits/external/hacks.h index b28f17e4..f56d2ba4 100644 --- a/src/core/include/units/bits/external/hacks.h +++ b/src/core/include/units/bits/external/hacks.h @@ -106,11 +106,21 @@ #if UNITS_COMP_MSVC -#define UNITS_MSVC_WORKAROUND(X) +#define UNITS_CONSTRAINED_AUTO_WORKAROUND(X) #else -#define UNITS_MSVC_WORKAROUND(X) X +#define UNITS_CONSTRAINED_AUTO_WORKAROUND(X) X + +#endif + +#if UNITS_COMP_MSVC || UNITS_COMP_GCC < 11 + +#define UNITS_CONSTRAINED_NTTP_WORKAROUND(X) + +#else + +#define UNITS_CONSTRAINED_NTTP_WORKAROUND(X) X #endif diff --git a/src/core/include/units/derived_dimension.h b/src/core/include/units/derived_dimension.h index 0af2e096..82f7b560 100644 --- a/src/core/include/units/derived_dimension.h +++ b/src/core/include/units/derived_dimension.h @@ -85,7 +85,7 @@ template struct derived_dimension : downcast_dispatch> { using recipe = exponent_list; using coherent_unit = U; - static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = + static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = detail::absolute_magnitude(typename derived_dimension::exponents()) / U::mag; }; diff --git a/src/core/include/units/prefix.h b/src/core/include/units/prefix.h index 803cf341..e3e036c9 100644 --- a/src/core/include/units/prefix.h +++ b/src/core/include/units/prefix.h @@ -36,7 +36,7 @@ namespace detail { template struct prefix_base : downcast_base> { - static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = M; + static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = M; }; } // namespace detail diff --git a/src/core/include/units/reference.h b/src/core/include/units/reference.h index c6a68fb1..2b29e280 100644 --- a/src/core/include/units/reference.h +++ b/src/core/include/units/reference.h @@ -94,7 +94,7 @@ template U> struct reference { using dimension = D; using unit = U; - static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = dimension::mag * unit::mag; + static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = dimension::mag * unit::mag; // Hidden Friends // Below friend functions are to be found via argument-dependent lookup only diff --git a/src/core/include/units/unit.h b/src/core/include/units/unit.h index f6a3aba1..a79dea07 100644 --- a/src/core/include/units/unit.h +++ b/src/core/include/units/unit.h @@ -64,7 +64,7 @@ inline constexpr bool can_be_prefixed = false; */ template struct scaled_unit : downcast_base> { - static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = M; + static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = M; using reference = U; };