From 5ddfdc8516e35c4f5de2613692d104486151171b Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Sun, 3 Oct 2021 22:08:03 +0200 Subject: Codechange: Declare our custom enum operators as constexpr. --- src/core/enum_type.hpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/core/enum_type.hpp b/src/core/enum_type.hpp index d4ea82eff..72e23ba36 100644 --- a/src/core/enum_type.hpp +++ b/src/core/enum_type.hpp @@ -12,13 +12,13 @@ /** Some enums need to have allowed incrementing (i.e. StationClassID) */ #define DECLARE_POSTFIX_INCREMENT(enum_type) \ - inline enum_type operator ++(enum_type& e, int) \ + inline constexpr enum_type operator ++(enum_type& e, int) \ { \ enum_type e_org = e; \ e = (enum_type)((std::underlying_type::type)e + 1); \ return e_org; \ } \ - inline enum_type operator --(enum_type& e, int) \ + inline constexpr enum_type operator --(enum_type& e, int) \ { \ enum_type e_org = e; \ e = (enum_type)((std::underlying_type::type)e - 1); \ @@ -29,13 +29,13 @@ /** Operators to allow to work with enum as with type safe bit set in C++ */ # define DECLARE_ENUM_AS_BIT_SET(mask_t) \ - inline mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type::type)m1 | m2);} \ - inline mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type::type)m1 & m2);} \ - inline mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type::type)m1 ^ m2);} \ - inline mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \ - inline mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \ - inline mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \ - inline mask_t operator ~(mask_t m) {return (mask_t)(~(std::underlying_type::type)m);} + inline constexpr mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type::type)m1 | m2);} \ + inline constexpr mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type::type)m1 & m2);} \ + inline constexpr mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type::type)m1 ^ m2);} \ + inline constexpr mask_t& operator |= (mask_t& m1, mask_t m2) {m1 = m1 | m2; return m1;} \ + inline constexpr mask_t& operator &= (mask_t& m1, mask_t m2) {m1 = m1 & m2; return m1;} \ + inline constexpr mask_t& operator ^= (mask_t& m1, mask_t m2) {m1 = m1 ^ m2; return m1;} \ + inline constexpr mask_t operator ~(mask_t m) {return (mask_t)(~(std::underlying_type::type)m);} /** -- cgit v1.2.3-70-g09d2