Is there a way to define a class that can be initialized like how enum does?
For example:
class TYPE;
TYPE _type {
a,
b,
c,
};
_type::a;
TYPE::TYPENAME tn = _type::c; // or such similar things
_type.get_size(); // the example returns 3
Is this kind of definition of class available in c++? If yes, would you please explain the method and how it works? If not, then I might use variadic templates for the implementation.
EDIT
If I made a class as I like, then the below code would work:
main.cpp
#include <iostream>
#include "advanced_enum_class_name_TYPE.h"
TYPE type { a, b, c }; // a, b, c have not been defined before this line
int main() {
type _type = type::a;
std::cout << type.get_size() << std::endl; // 3
if(_type == type::b) { // false
std::cout << "it is b!" << std::endl;
}
else {
std::cout << "it is not b!" << std::endl;
}
}