diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index 3d7b2a88..2aebf72b 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -25,21 +25,26 @@ #include "validated_type.h" #include #include +#include #include -template +template auto Min, std::convertible_to auto Max> inline constexpr auto is_in_range = [](const auto& v) { return std::clamp(v, T{Min}, T{Max}) == v; }; -template +template auto Min, std::convertible_to auto Max> using is_in_range_t = decltype(is_in_range); -template +template auto Min, std::convertible_to auto Max> class ranged_representation : public validated_type> { public: using validated_type>::validated_type; constexpr ranged_representation() : validated_type>(T{}) {} - [[nodiscard]] constexpr ranged_representation operator-() const { return ranged_representation(-this->value()); } + [[nodiscard]] constexpr ranged_representation operator-() const + requires requires(T t) { -t; } + { + return ranged_representation(-this->value()); + } }; template