vendredi 22 juillet 2016

What is the difference between enum struct and enum class?

Looking at the enum documentation, there was one thing that I noticed:

enum-key - one of enum, enum class(since C++11), or enum struct(since C++11)

enum and enum class, sure, but what is a enum struct?

The docs seem to say that enum class and enum struct are exactly the same:

[...] scoped enumeration (declared with the enum-key enum class or enum struct)


  • enum struct|class name { enumerator = constexpr , enumerator = constexpr , ... }
  • [...]

Are they really exactly the same? Or are there any differences that I missed? What is the point (if they are the same) to have 2 different syntax for the same thing?

Aucun commentaire:

Enregistrer un commentaire