From 71197c46412febc58479226bfa631fbbe33f9d35 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 4 Nov 2014 22:18:37 +0000 Subject: [PATCH] Tweak flags implementation --- src/flags.hh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/flags.hh b/src/flags.hh index a3cbc5e0..10e05187 100644 --- a/src/flags.hh +++ b/src/flags.hh @@ -10,7 +10,7 @@ template struct WithBitOps : std::false_type {}; template -using EnumStorageType = typename std::underlying_type::type; +using UnderlyingType = typename std::underlying_type::type; template using EnableIfWithBitOps = typename std::enable_if::value>::type; @@ -18,33 +18,33 @@ using EnableIfWithBitOps = typename std::enable_if::value>::ty template> constexpr Flags operator|(Flags lhs, Flags rhs) { - return (Flags)((EnumStorageType) lhs | (EnumStorageType) rhs); + return (Flags)((UnderlyingType) lhs | (UnderlyingType) rhs); } template> Flags& operator|=(Flags& lhs, Flags rhs) { - (EnumStorageType&) lhs |= (EnumStorageType) rhs; + (UnderlyingType&) lhs |= (UnderlyingType) rhs; return lhs; } template> constexpr bool operator&(Flags lhs, Flags rhs) { - return ((EnumStorageType) lhs & (EnumStorageType) rhs) != 0; + return ((UnderlyingType) lhs & (UnderlyingType) rhs) == (UnderlyingType)rhs; } template> Flags& operator&=(Flags& lhs, Flags rhs) { - (EnumStorageType&) lhs &= (EnumStorageType) rhs; + (UnderlyingType&) lhs &= (UnderlyingType) rhs; return lhs; } template> constexpr Flags operator~(Flags lhs) { - return (Flags)(~(EnumStorageType)lhs); + return (Flags)(~(UnderlyingType)lhs); } }