diff options
author | Rainer Deyke <rainerd@eldwood.com> | 2022-04-01 11:04:25 +0200 |
---|---|---|
committer | Rainer Deyke <rainerd@eldwood.com> | 2022-04-04 14:56:37 +0200 |
commit | 2907ca3a4160efd9e8afe1f636f87df5e6964134 (patch) | |
tree | 37c04dba5a71118ea90d95d8fbcb868ffc7051c5 /core/os | |
parent | 338b23d57224ecd04eaff4763a7ba493ffa6cb3d (diff) |
Made Key operators constexpr
Made operators on Key and KeyModifierMask constexpr, allowing them to
be used in switch cases.
Diffstat (limited to 'core/os')
-rw-r--r-- | core/os/keyboard.h | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/core/os/keyboard.h b/core/os/keyboard.h index a21d81b2e7..9464f4305a 100644 --- a/core/os/keyboard.h +++ b/core/os/keyboard.h @@ -310,67 +310,67 @@ enum class KeyModifierMask { // To avoid having unnecessary operators, only define the ones that are needed. -inline Key operator-(uint32_t a, Key b) { +constexpr Key operator-(uint32_t a, Key b) { return (Key)(a - (uint32_t)b); } -inline Key &operator-=(Key &a, int b) { +constexpr Key &operator-=(Key &a, int b) { return (Key &)((int &)a -= b); } -inline Key operator+(Key a, int b) { +constexpr Key operator+(Key a, int b) { return (Key)((int)a + (int)b); } -inline Key operator+(Key a, Key b) { +constexpr Key operator+(Key a, Key b) { return (Key)((int)a + (int)b); } -inline Key operator-(Key a, Key b) { +constexpr Key operator-(Key a, Key b) { return (Key)((int)a - (int)b); } -inline Key operator&(Key a, Key b) { +constexpr Key operator&(Key a, Key b) { return (Key)((int)a & (int)b); } -inline Key operator|(Key a, Key b) { +constexpr Key operator|(Key a, Key b) { return (Key)((int)a | (int)b); } -inline Key &operator|=(Key &a, Key b) { +constexpr Key &operator|=(Key &a, Key b) { return (Key &)((int &)a |= (int)b); } -inline Key &operator|=(Key &a, KeyModifierMask b) { +constexpr Key &operator|=(Key &a, KeyModifierMask b) { return (Key &)((int &)a |= (int)b); } -inline Key &operator&=(Key &a, KeyModifierMask b) { +constexpr Key &operator&=(Key &a, KeyModifierMask b) { return (Key &)((int &)a &= (int)b); } -inline Key operator|(Key a, KeyModifierMask b) { +constexpr Key operator|(Key a, KeyModifierMask b) { return (Key)((int)a | (int)b); } -inline Key operator&(Key a, KeyModifierMask b) { +constexpr Key operator&(Key a, KeyModifierMask b) { return (Key)((int)a & (int)b); } -inline Key operator+(KeyModifierMask a, Key b) { +constexpr Key operator+(KeyModifierMask a, Key b) { return (Key)((int)a + (int)b); } -inline Key operator|(KeyModifierMask a, Key b) { +constexpr Key operator|(KeyModifierMask a, Key b) { return (Key)((int)a | (int)b); } -inline KeyModifierMask operator+(KeyModifierMask a, KeyModifierMask b) { +constexpr KeyModifierMask operator+(KeyModifierMask a, KeyModifierMask b) { return (KeyModifierMask)((int)a + (int)b); } -inline KeyModifierMask operator|(KeyModifierMask a, KeyModifierMask b) { +constexpr KeyModifierMask operator|(KeyModifierMask a, KeyModifierMask b) { return (KeyModifierMask)((int)a | (int)b); } |