mercredi 13 janvier 2021

Refactoring to enum to enum class shadows namespace

In previous codebase I have :

namespace E {
enum { a, b }
void foo();
}

I want to refactor to using enum class:

enum class E : int { a, b }
namespace E {
void foo();
}

However this fails to compile because now namespace E can't be used as it has same name as enum. Is there a way around this ? Basically I still want that the calling code compile as-is, which is using either E::foo() or E::a

Aucun commentaire:

Enregistrer un commentaire