From 48b931fbb0ce0c2ca1f36cae7a40ee6aa4e0ecf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johel=20Ernesto=20Guerrero=20Pe=C3=B1a?= Date: Sat, 23 Sep 2023 15:53:46 -0400 Subject: [PATCH] fix(example): make `ranged_representation` model `vector_space` --- example/include/ranged_representation.h | 28 ++++++------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/example/include/ranged_representation.h b/example/include/ranged_representation.h index ea028fb2e..f22e83bcc 100644 --- a/example/include/ranged_representation.h +++ b/example/include/ranged_representation.h @@ -45,35 +45,19 @@ class ranged_representation : public validated_type>::validated_type; constexpr ranged_representation() : validated_type>(T{}) {} - [[nodiscard]] constexpr ranged_representation operator-() const - requires requires(T t) { -t; } - { - return ranged_representation(-this->value()); - } - - [[nodiscard]] friend constexpr ranged_representation operator-(const ranged_representation& lhs, - const ranged_representation& rhs) - { - return ranged_representation(lhs.value() - rhs.value()); - } + [[nodiscard]] constexpr ranged_representation operator-() const { return ranged_representation(-this->value()); } - constexpr ranged_representation& operator+=(const ranged_representation& that) + constexpr ranged_representation& operator+=(const T& that) { - this->value() += that.value(); - gsl_Expects(validate(this->value())); - return *this; + return *this = ranged_representation(this->value() + that); } - constexpr ranged_representation& operator-=(const ranged_representation& that) + constexpr ranged_representation& operator-=(const T& that) { - this->value() -= that.value(); - gsl_Expects(validate(this->value())); - return *this; + return *this = ranged_representation(this->value() - that); } constexpr ranged_representation& operator*=(const T& rhs) { - this->value() *= rhs; - gsl_Expects(validate(this->value())); - return *this; + return *this = ranged_representation(this->value() * rhs); } };