mirror of
https://github.com/mpusz/mp-units.git
synced 2025-07-31 19:04:27 +02:00
my_value toy class refactored
This commit is contained in:
@@ -32,16 +32,14 @@ namespace {
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
class my_value {
|
class my_value {
|
||||||
T value_{};
|
T value_{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
my_value() = default;
|
my_value() = default;
|
||||||
constexpr my_value(T v) : value_{v} {}
|
constexpr my_value(T v) : value_{std::move(v)} {}
|
||||||
constexpr my_value& operator+=(const my_value& other) { value_ += other.value_; return *this; }
|
constexpr my_value& operator+=(const my_value& other) { value_ += other.value_; return *this; }
|
||||||
constexpr my_value& operator-=(const my_value& other) { value_ -= other.value_; return *this; }
|
constexpr my_value& operator-=(const my_value& other) { value_ -= other.value_; return *this; }
|
||||||
constexpr my_value& operator*=(const my_value& other) { value_ *= other.value_; return *this; }
|
constexpr my_value& operator*=(const my_value& other) { value_ *= other.value_; return *this; }
|
||||||
constexpr my_value& operator/=(const my_value& other) { value_ /= other.value_; return *this; }
|
constexpr my_value& operator/=(const my_value& other) { value_ /= other.value_; return *this; }
|
||||||
constexpr operator const T&() const { return value_; }
|
constexpr operator const T&() const & { return value_; }
|
||||||
constexpr operator T&() { return value_; }
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
Reference in New Issue
Block a user