C++17: still using enums as constants?

This is subjective.

However, this was always an abuse of enums. You're not enumerating anything; you're just stealing the enum feature to get some unrelated with arbitrary integer values which are not intended to have their own logical "type".

That's why enum class is not appropriate here either (because, as you pointed out, enum class enforces the properties of an enum that should be there but which you do not actually want).

Since there's no longer any problem with static constexpr int, I'd use that (or constexpr inline int, or whatever it is this week).

Tags:

C++

Enums

C++17