@@ -38,7 +38,7 @@ template<std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_t
3838 MP_UNITS_CONSTRAINED_NTTP_WORKAROUND (std::convertible_to<T>) auto Max>
3939using is_in_range_t = decltype(is_in_range<T, Min, Max>);
4040
41- template <std::movable T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
41+ template <mp_units::vector_space T, MP_UNITS_CONSTRAINED_NTTP_WORKAROUND(std::convertible_to<T>) auto Min,
4242 MP_UNITS_CONSTRAINED_NTTP_WORKAROUND (std::convertible_to<T>) auto Max>
4343class ranged_representation : public validated_type<T, is_in_range_t<T, Min, Max>> {
4444public:
@@ -50,15 +50,44 @@ class ranged_representation : public validated_type<T, is_in_range_t<T, Min, Max
5050 {
5151 return ranged_representation (-this ->value ());
5252 }
53+
54+ friend constexpr ranged_representation operator -(const ranged_representation& lhs, const ranged_representation& rhs)
55+ {
56+ return ranged_representation (lhs.value () - rhs.value ());
57+ }
58+
59+ constexpr ranged_representation& operator +=(ranged_representation that)
60+ {
61+ this ->value () += that.value ();
62+ gsl_Expects (validate (this ->value ()));
63+ return *this ;
64+ }
65+ constexpr ranged_representation& operator -=(ranged_representation that)
66+ {
67+ this ->value () -= that.value ();
68+ gsl_Expects (validate (this ->value ()));
69+ return *this ;
70+ }
71+ constexpr ranged_representation& operator *=(T rhs)
72+ {
73+ this ->value () *= rhs;
74+ gsl_Expects (validate (this ->value ()));
75+ return *this ;
76+ }
5377};
5478
5579template <typename T, auto Min, auto Max>
5680inline constexpr bool mp_units::is_scalar<ranged_representation<T, Min, Max>> = mp_units::is_scalar<T>;
5781
82+ template <typename T, auto Min, auto Max>
83+ struct mp_units ::number_scalar<ranged_representation<T, Min, Max>> : std::type_identity<T> {};
84+
5885template <typename T, auto Min, auto Max>
5986inline constexpr bool mp_units::treat_as_floating_point<ranged_representation<T, Min, Max>> =
6087 mp_units::treat_as_floating_point<T>;
6188
89+ static_assert (mp_units::vector_space<ranged_representation<int , 17 , 29 >>);
90+
6291template <typename T, auto Min, auto Max>
6392struct MP_UNITS_STD_FMT ::formatter<ranged_representation<T, Min, Max>> : formatter<T> {
6493 template <typename FormatContext>
0 commit comments