From 630119350bd083d7a63b8cfea6afc11e5b7fac76 Mon Sep 17 00:00:00 2001 From: Jack Andersen Date: Tue, 2 Apr 2019 18:29:35 -1000 Subject: [PATCH] Add True and False tests for bitwise enums --- include/kabufuda/Util.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/kabufuda/Util.hpp b/include/kabufuda/Util.hpp index 552500d..4fc10b0 100644 --- a/include/kabufuda/Util.hpp +++ b/include/kabufuda/Util.hpp @@ -60,6 +60,14 @@ constexpr type operator~(type key) { \ using T = std::underlying_type_t; \ return type(~static_cast(key)); \ + } \ + constexpr bool True(type key) { \ + using T = std::underlying_type_t; \ + return static_cast(key) != 0; \ + } \ + constexpr bool False(type key) { \ + using T = std::underlying_type_t; \ + return static_cast(key) == 0; \ } #endif