Skip to content

Commit

Permalink
Add compare operators between Enum and enumerated
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas BRUNEL <[email protected]>
  • Loading branch information
thomas-brunel committed Apr 22, 2023
1 parent 1e8f499 commit 7b179d6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -942,18 +942,50 @@ inline bool operator <(const Enum &a, const Enum &b) \
{ return a._to_integral() < b._to_integral(); } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator <(const Enum &a, const Enum::_enumerated &b) \
{ return a._to_integral() < b; } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator <(const Enum::_enumerated &a, const Enum &b) \
{ return a < b._to_integral(); } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator <=(const Enum &a, const Enum &b) \
{ return a._to_integral() <= b._to_integral(); } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator <=(const Enum &a, const Enum::_enumerated &b) \
{ return a._to_integral() <= b; } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator <=(const Enum::_enumerated &a, const Enum &b) \
{ return a <= b._to_integral(); } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator >(const Enum &a, const Enum &b) \
{ return a._to_integral() > b._to_integral(); } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator >(const Enum &a, const Enum::_enumerated &b) \
{ return a._to_integral() > b; } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator >(const Enum::_enumerated &a, const Enum &b) \
{ return a > b._to_integral(); } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator >=(const Enum &a, const Enum &b) \
{ return a._to_integral() >= b._to_integral(); } \
BETTER_ENUMS_IGNORE_ATTRIBUTES_END \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator >=(const Enum &a, const Enum::_enumerated &b) \
{ return a._to_integral() >= b; } \
\
BETTER_ENUMS_UNUSED BETTER_ENUMS_CONSTEXPR_ \
inline bool operator >=(const Enum::_enumerated &a, const Enum &b) \
{ return a >= b._to_integral(); } \
\
\
template <typename Char, typename Traits> \
std::basic_ostream<Char, Traits>& \
Expand Down

0 comments on commit 7b179d6

Please sign in to comment.