summaryrefslogtreecommitdiff
path: root/src/units.hh
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2013-01-14 18:51:45 +0100
committerMaxime Coste <frrrwww@gmail.com>2013-01-14 18:51:45 +0100
commiteaaf88db1d3561161dd4d519f3d5952539eaef04 (patch)
treec1167c716ff316b9d6ba5d12988b93c2d4b17189 /src/units.hh
parent3d00f398feeee5e067c456223167fb092199b3db (diff)
rename StronglyTypedInteger to more accurate StronglyTypedNumber
Diffstat (limited to 'src/units.hh')
-rw-r--r--src/units.hh24
1 files changed, 15 insertions, 9 deletions
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 <type_traits>
+
namespace Kakoune
{
template<typename RealType, typename ValueType = int>
-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<StronglyTypedNumber, RealType>::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<LineCount, int>
+struct LineCount : public StronglyTypedNumber<LineCount, int>
{
- constexpr LineCount(int value) : StronglyTypedInteger<LineCount>(value) {}
+ constexpr LineCount(int value) : StronglyTypedNumber<LineCount>(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<ByteCount, int>
+struct ByteCount : public StronglyTypedNumber<ByteCount, int>
{
- constexpr ByteCount(int value) : StronglyTypedInteger<ByteCount>(value) {}
+ constexpr ByteCount(int value) : StronglyTypedNumber<ByteCount>(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<CharCount, int>
+struct CharCount : public StronglyTypedNumber<CharCount, int>
{
- constexpr CharCount(int value) : StronglyTypedInteger<CharCount>(value) {}
+ constexpr CharCount(int value) : StronglyTypedNumber<CharCount>(value) {}
};
inline constexpr CharCount operator"" _char(unsigned long long int value)