From 2d15716b5f6aa2aab6c0dcf7b6ac99ecfeda3f72 Mon Sep 17 00:00:00 2001 From: Rasmus Karlsson Date: Sat, 31 Mar 2018 11:23:07 +0200 Subject: [PATCH] Add helper methods to FlagsEnum where I can make sure that it actually works forsenT --- src/util/flagsenum.hpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/util/flagsenum.hpp b/src/util/flagsenum.hpp index 08a7ea55b..9e5daed26 100644 --- a/src/util/flagsenum.hpp +++ b/src/util/flagsenum.hpp @@ -12,7 +12,7 @@ class FlagsEnum { public: FlagsEnum() - : value((T)0) + : value(static_cast(0)) { } @@ -50,7 +50,18 @@ public: return (T &)((Q &)this->value ^= (Q)a); } + void EnableFlag(T flag) + { + reinterpret_cast(this->value) |= static_cast(flag); + } + + bool HasFlag(Q flag) const + { + return (this->value & flag) == flag; + } + T value; }; + } // namespace util } // namespace chatterino