diff --git a/src/units.hh b/src/units.hh index 8fdfcacd..568d8b12 100644 --- a/src/units.hh +++ b/src/units.hh @@ -1,15 +1,21 @@ #ifndef units_hh_INCLUDED #define units_hh_INCLUDED +#include + namespace Kakoune { template -class StronglyTypedInteger +class StronglyTypedNumber { public: - explicit constexpr StronglyTypedInteger(ValueType value) - : m_value(value) {} + explicit constexpr StronglyTypedNumber(ValueType value) + : m_value(value) + { + static_assert(std::is_base_of::value, + "RealType is not derived from StronglyTypedNumber"); + } constexpr RealType operator+(const RealType& other) const { return RealType(m_value + other.m_value); } @@ -76,9 +82,9 @@ private: ValueType m_value; }; -struct LineCount : public StronglyTypedInteger +struct LineCount : public StronglyTypedNumber { - constexpr LineCount(int value) : StronglyTypedInteger(value) {} + constexpr LineCount(int value) : StronglyTypedNumber(value) {} }; inline constexpr LineCount operator"" _line(unsigned long long int value) @@ -86,9 +92,9 @@ inline constexpr LineCount operator"" _line(unsigned long long int value) return LineCount(value); } -struct ByteCount : public StronglyTypedInteger +struct ByteCount : public StronglyTypedNumber { - constexpr ByteCount(int value) : StronglyTypedInteger(value) {} + constexpr ByteCount(int value) : StronglyTypedNumber(value) {} }; inline constexpr ByteCount operator"" _byte(unsigned long long int value) @@ -96,9 +102,9 @@ inline constexpr ByteCount operator"" _byte(unsigned long long int value) return ByteCount(value); } -struct CharCount : public StronglyTypedInteger +struct CharCount : public StronglyTypedNumber { - constexpr CharCount(int value) : StronglyTypedInteger(value) {} + constexpr CharCount(int value) : StronglyTypedNumber(value) {} }; inline constexpr CharCount operator"" _char(unsigned long long int value)