forked from mpusz/mp-units
fix: a workaround for compilation error on MSVC and gcc-10 added
This commit is contained in:
@@ -28,13 +28,16 @@
|
|||||||
#include <concepts>
|
#include <concepts>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
template<std::movable T, std::convertible_to<T> auto Min, std::convertible_to<T> auto Max>
|
template<std::movable T, UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
|
||||||
|
UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>
|
||||||
inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; };
|
inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; };
|
||||||
|
|
||||||
template<std::movable T, std::convertible_to<T> auto Min, std::convertible_to<T> auto Max>
|
template<std::movable T, UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
|
||||||
|
UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>
|
||||||
using is_in_range_t = decltype(is_in_range<T, Min, Max>);
|
using is_in_range_t = decltype(is_in_range<T, Min, Max>);
|
||||||
|
|
||||||
template<std::movable T, std::convertible_to<T> auto Min, std::convertible_to<T> auto Max>
|
template<std::movable T, UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
|
||||||
|
UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Max>
|
||||||
class ranged_representation : public validated_type<T, is_in_range_t<T, Min, Max>> {
|
class ranged_representation : public validated_type<T, is_in_range_t<T, Min, Max>> {
|
||||||
public:
|
public:
|
||||||
using validated_type<T, is_in_range_t<T, Min, Max>>::validated_type;
|
using validated_type<T, is_in_range_t<T, Min, Max>>::validated_type;
|
||||||
|
@@ -54,7 +54,7 @@ template<basic_fixed_string Symbol, NamedUnit U>
|
|||||||
struct base_dimension {
|
struct base_dimension {
|
||||||
static constexpr auto symbol = Symbol; ///< Unique base dimension identifier
|
static constexpr auto symbol = Symbol; ///< Unique base dimension identifier
|
||||||
using base_unit = U; ///< Base unit adopted for this dimension
|
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
|
// base_dimension_less
|
||||||
|
@@ -66,8 +66,8 @@ struct common_quantity_reference_impl<reference<D1, U1>, reference<D2, U2>> {
|
|||||||
|
|
||||||
template<typename D1, typename U1, typename D2, typename U2>
|
template<typename D1, typename U1, typename D2, typename U2>
|
||||||
struct common_quantity_reference_impl<reference<D1, U1>, reference<D2, U2>> {
|
struct common_quantity_reference_impl<reference<D1, U1>, reference<D2, U2>> {
|
||||||
static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = common_magnitude(reference<D1, U1>::mag,
|
static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = common_magnitude(reference<D1, U1>::mag,
|
||||||
reference<D2, U2>::mag);
|
reference<D2, U2>::mag);
|
||||||
using dimension = conditional<is_specialization_of<D1, unknown_dimension>, D2, D1>;
|
using dimension = conditional<is_specialization_of<D1, unknown_dimension>, D2, D1>;
|
||||||
using unit = downcast_unit<dimension, mag / dimension::mag>;
|
using unit = downcast_unit<dimension, mag / dimension::mag>;
|
||||||
using type = reference<dimension, unit>;
|
using type = reference<dimension, unit>;
|
||||||
|
14
src/core/include/units/bits/external/hacks.h
vendored
14
src/core/include/units/bits/external/hacks.h
vendored
@@ -106,11 +106,21 @@
|
|||||||
|
|
||||||
#if UNITS_COMP_MSVC
|
#if UNITS_COMP_MSVC
|
||||||
|
|
||||||
#define UNITS_MSVC_WORKAROUND(X)
|
#define UNITS_CONSTRAINED_AUTO_WORKAROUND(X)
|
||||||
|
|
||||||
#else
|
#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
|
#endif
|
||||||
|
|
||||||
|
@@ -85,7 +85,7 @@ template<typename Child, Unit U, Exponent... Es>
|
|||||||
struct derived_dimension : downcast_dispatch<Child, typename detail::make_dimension<Es...>> {
|
struct derived_dimension : downcast_dispatch<Child, typename detail::make_dimension<Es...>> {
|
||||||
using recipe = exponent_list<Es...>;
|
using recipe = exponent_list<Es...>;
|
||||||
using coherent_unit = U;
|
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;
|
detail::absolute_magnitude(typename derived_dimension::exponents()) / U::mag;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ namespace detail {
|
|||||||
|
|
||||||
template<Magnitude auto M>
|
template<Magnitude auto M>
|
||||||
struct prefix_base : downcast_base<prefix_base<M>> {
|
struct prefix_base : downcast_base<prefix_base<M>> {
|
||||||
static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = M;
|
static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = M;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
@@ -94,7 +94,7 @@ template<Dimension D, UnitOf<D> U>
|
|||||||
struct reference {
|
struct reference {
|
||||||
using dimension = D;
|
using dimension = D;
|
||||||
using unit = U;
|
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
|
// Hidden Friends
|
||||||
// Below friend functions are to be found via argument-dependent lookup only
|
// Below friend functions are to be found via argument-dependent lookup only
|
||||||
|
@@ -64,7 +64,7 @@ inline constexpr bool can_be_prefixed = false;
|
|||||||
*/
|
*/
|
||||||
template<Magnitude auto M, typename U>
|
template<Magnitude auto M, typename U>
|
||||||
struct scaled_unit : downcast_base<scaled_unit<M, U>> {
|
struct scaled_unit : downcast_base<scaled_unit<M, U>> {
|
||||||
static constexpr UNITS_MSVC_WORKAROUND(Magnitude) auto mag = M;
|
static constexpr UNITS_CONSTRAINED_AUTO_WORKAROUND(Magnitude) auto mag = M;
|
||||||
using reference = U;
|
using reference = U;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user