diff options
author | Michael Lutz <michi@icosahedron.de> | 2021-10-03 22:08:03 +0200 |
---|---|---|
committer | Michael Lutz <michi@icosahedron.de> | 2021-12-16 22:28:32 +0100 |
commit | 5ddfdc8516e35c4f5de2613692d104486151171b (patch) | |
tree | 54b901afc61449c98c5e7d06c123d01af59144b7 /src/core | |
parent | a38bbefe1b28ac59b2a9fef45765fa3890cde32e (diff) | |
download | openttd-5ddfdc8516e35c4f5de2613692d104486151171b.tar.xz |
Codechange: Declare our custom enum operators as constexpr.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/enum_type.hpp | 18 |
1 files changed, 9 insertions, 9 deletions
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<enum_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<enum_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<mask_t>::type)m1 | m2);} \ - inline mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 & m2);} \ - inline mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::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<mask_t>::type)m);} + inline constexpr mask_t operator | (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 | m2);} \ + inline constexpr mask_t operator & (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::type)m1 & m2);} \ + inline constexpr mask_t operator ^ (mask_t m1, mask_t m2) {return (mask_t)((std::underlying_type<mask_t>::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<mask_t>::type)m);} /** |