From c598201d113fb3ae7ca133980fa1701e8157dc2d Mon Sep 17 00:00:00 2001 From: Mateusz Pusz Date: Fri, 22 Apr 2022 13:07:01 +0200 Subject: [PATCH] fix: `ranged_representation` refactored to work with older compilers --- example/glide_computer/include/geographic.h | 5 +++-- example/include/ranged_representation.h | 22 +++++++++------------ 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/example/glide_computer/include/geographic.h b/example/glide_computer/include/geographic.h index e8a56714..9c72b1e0 100644 --- a/example/glide_computer/include/geographic.h +++ b/example/glide_computer/include/geographic.h @@ -28,6 +28,7 @@ #include #include #include +#include #include // IWYU pragma: begin_exports @@ -38,10 +39,10 @@ namespace geographic { // TODO Change to `angle` dimension in degree unit when the work on magnitudes is done template -using latitude = units::dimensionless>; +using latitude = units::dimensionless>; template -using longitude = units::dimensionless>; +using longitude = units::dimensionless>; template std::basic_ostream& operator<<(std::basic_ostream& os, const latitude& lat) diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index 8d5ec234..b620729e 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -26,27 +26,23 @@ #include #include -template -inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, Min, Max) == v; }; +template +inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; }; -template -class ranged_representation : public validated_type)> { +template +class ranged_representation : public validated_type)> { public: - using base = validated_type)>; + using base = validated_type)>; using base::validated_type; constexpr ranged_representation() : base(T{}) {} [[nodiscard]] constexpr ranged_representation operator-() const { return ranged_representation(-this->value()); } }; -template +template struct std::common_type> : - std::type_identity< - ranged_representation, std::common_type_t{Min}, - std::common_type_t{Max}>> {}; + std::type_identity, Min, Max>> {}; -template +template struct std::common_type, std::intmax_t> : - std::type_identity< - ranged_representation, std::common_type_t{Min}, - std::common_type_t{Max}>> {}; + std::type_identity, Min, Max>> {};