From f7eab25947d3e1f8164d8091596dab0214dd9c34 Mon Sep 17 00:00:00 2001 From: Kitzunu <24550914+Kitzunu@users.noreply.github.com> Date: Tue, 28 Sep 2021 18:06:56 +0200 Subject: chore: enum class > enum --- docs/cpp-code-standards.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'docs/cpp-code-standards.md') diff --git a/docs/cpp-code-standards.md b/docs/cpp-code-standards.md index 5d5128c..46102b3 100644 --- a/docs/cpp-code-standards.md +++ b/docs/cpp-code-standards.md @@ -121,6 +121,19 @@ enum Spells constexpr uint32 SPELL_4 = 4444; ``` +### Enum vs. Enum Class + +Enum classes are prefered to be used as they can cause fewer suprises that could lead to bugs as the enum will not implicitly convert to other types like integer or other enums. + +```cpp +enum class Spell : uint32 +{ + One = 1111, + Two = 2222, + Three = 3333 +} +``` + ### Standard prefixes for constants All constants that we store have a standardized prefix. -- cgit