From 8fcf28a5fea1109b4acc96a83ec072aa466fb76d Mon Sep 17 00:00:00 2001 From: Anton Bachin Date: Sun, 3 May 2015 05:45:52 -0400 Subject: [PATCH] Made comparison operators constexpr. --- EnumInternal.h | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/EnumInternal.h b/EnumInternal.h index a0a64b4..1cf091d 100644 --- a/EnumInternal.h +++ b/EnumInternal.h @@ -682,42 +682,40 @@ class _Enum : public _GeneratedArrays { _from_string_nocase_loop(name, throw_exception, index + 1); } - // TODO Make many of these constexpr. - // TODO Review which operators should be present. public: - bool operator ==(const _Enum &other) const + constexpr bool operator ==(const _Enum &other) const { return _value == other._value; } - bool operator ==(const _Enumerated value) const + constexpr bool operator ==(const _Enumerated value) const { return _value == value; } template bool operator ==(T other) const = delete; - bool operator !=(const _Enum &other) const + constexpr bool operator !=(const _Enum &other) const { return !(*this == other); } - bool operator !=(const _Enumerated value) const + constexpr bool operator !=(const _Enumerated value) const { return !(*this == value); } template bool operator !=(T other) const = delete; - bool operator <(const _Enum &other) const + constexpr bool operator <(const _Enum &other) const { return _value < other._value; } - bool operator <(const _Enumerated value) const + constexpr bool operator <(const _Enumerated value) const { return _value < value; } template bool operator <(T other) const = delete; - bool operator <=(const _Enum &other) const + constexpr bool operator <=(const _Enum &other) const { return _value <= other._value; } - bool operator <=(const _Enumerated value) const + constexpr bool operator <=(const _Enumerated value) const { return _value <= value; } template bool operator <=(T other) const = delete; - bool operator >(const _Enum &other) const + constexpr bool operator >(const _Enum &other) const { return _value > other._value; } - bool operator >(const _Enumerated value) const + constexpr bool operator >(const _Enumerated value) const { return _value > value; } template bool operator >(T other) const = delete; - bool operator >=(const _Enum &other) const + constexpr bool operator >=(const _Enum &other) const { return _value >= other._value; } - bool operator >=(const _Enumerated value) const + constexpr bool operator >=(const _Enumerated value) const { return _value >= value; } template bool operator >=(T other) const = delete;