I was just looking over the implementation of the ResourceHolder class again yesterday and recognized that ResourceIdentifiers.hpp uses enums nested in namespaces. I think the main purpose of this would be to "emulate" strongly typed enums (as of c++ enums are not strongly typed) so that no name conflicts arise.
C++11 offers enum classes which serve the purpose of strongly typed enums, so that one is enforced to use the strong name of an enum member.
So my question is, could the following code
namespace Textures
{
enum ID
{
Eagle,
Raptor,
Desert,
};
}
be rewritten to
enum class TextureID
{
Eagle,
Raptor,
Desert,
};
to accomplish the same goal? One must then reference to a member of this enum class via TextureID::Eagle instead of Texture::Eagle.
I don't want to do this just for the features sake, but to eliminate the additional namespace, because I think it's a not intended use for a namespace, and an enum class is a real type compared to a classical enum.
I think this is a worthwhile refactor, but would like to here more expert opinions on this.
Thanks in advance.