From 660df8f7e614fa32b54e9fe146a492ce159ded31 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 9 Sep 2019 21:00:41 -0400 Subject: [PATCH 1/2] System: Make enum functions noexcept Allows them to be used within noexcept contexts --- include/boo/System.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/boo/System.hpp b/include/boo/System.hpp index 509bec2..15cfe4f 100644 --- a/include/boo/System.hpp +++ b/include/boo/System.hpp @@ -29,33 +29,33 @@ static inline ComPtr* ReferenceComPtr(ComPtr& ptr) { #ifndef ENABLE_BITWISE_ENUM #define ENABLE_BITWISE_ENUM(type) \ - constexpr type operator|(type a, type b) { \ + constexpr type operator|(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return type(static_cast(a) | static_cast(b)); \ } \ - constexpr type operator&(type a, type b) { \ + constexpr type operator&(type a, type b) noexcept { \ using T = std::underlying_type_t; \ return type(static_cast(a) & static_cast(b)); \ } \ - constexpr type& operator|=(type& a, type b) { \ + constexpr type& operator|=(type& a, type b) noexcept { \ using T = std::underlying_type_t; \ a = type(static_cast(a) | static_cast(b)); \ return a; \ } \ - constexpr type& operator&=(type& a, type b) { \ + constexpr type& operator&=(type& a, type b) noexcept { \ using T = std::underlying_type_t; \ a = type(static_cast(a) & static_cast(b)); \ return a; \ } \ - constexpr type operator~(type key) { \ + constexpr type operator~(type key) noexcept { \ using T = std::underlying_type_t; \ return type(~static_cast(key)); \ } \ - constexpr bool True(type key) { \ + constexpr bool True(type key) noexcept { \ using T = std::underlying_type_t; \ return static_cast(key) != 0; \ } \ - constexpr bool False(type key) { \ + constexpr bool False(type key) noexcept { \ using T = std::underlying_type_t; \ return static_cast(key) == 0; \ } From f2ab814ce1488314da8787fab8852d7f66c8f837 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 9 Sep 2019 21:02:28 -0400 Subject: [PATCH 2/2] System: Implement False() in terms of True() This is just a negation, so we can do this to place the logic in one spot. --- include/boo/System.hpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/boo/System.hpp b/include/boo/System.hpp index 15cfe4f..7e03e10 100644 --- a/include/boo/System.hpp +++ b/include/boo/System.hpp @@ -56,8 +56,7 @@ static inline ComPtr* ReferenceComPtr(ComPtr& ptr) { return static_cast(key) != 0; \ } \ constexpr bool False(type key) noexcept { \ - using T = std::underlying_type_t; \ - return static_cast(key) == 0; \ + return !True(key); \ } #endif