I've found the following pattern used fairly commonly in our company's code.
struct Foo
{
enum FType
{
TypeA,
TypeB,
Type_MAX
};
};
typedef Foo::FType FooType;
[...]
FooType m_type;
My question is, what is the benefit of this? (Or, what problem does this avoid?) To be clear, I am wondering why they didn't just...
enum FooType
{
TypeA,
TypeB,
Type_MAX
};
[...]
FooType m_type;
I can't ask the original programmer because they have been re-assigned, and it turns out that the designated subject matter expert in our company is, in fact, me.
If it helps, this code has been compiled at various times using many versions of MSVC, gcc, and clang for different target platforms... all pre C++11.
Can anyone see why this was done? Apologies in advance, if the answer turns out to be something trivial.
Edited to add: This is used inside classes. (When an enum is global, our style guide requires entries to begin with a common prefix, in order to distinguish them from other symbols.)