I am using a scoped enum to enumerate states in some state machine that I'm implementing. For example, let's say something like:
enum class CatState
{
sleeping,
napping,
resting
};
In my cpp file where I define a state transition table, I would like to use something equivalent to using namespace X
so that I don't need to prefix all my state names with CatState::
. In other words, I'd like to use sleeping
instead of CatState::sleeping
. My transition table has quite a few columns, so avoiding the CatState::
prefix would keep things more compact and readable.
So, is there a way to avoid having to type CatState::
all the time?
Yeah, yeah, I'm already aware of the pitfalls of using namespace
. If there's an equivalent for strongly-typed enums, I promise to only use it inside a limited scope in my cpp implementation file, and not for evil.