I'd like to choose between two different code paths depending on the value of an enum for a singleton class. Singleton classes inherit from a "CSingleton" type, where T is the type of the new class.
enum class Paths
{
PATH_ONE = 0,
PATH_TWO,
}
template<Paths pathValue>
class Foo : public CSingleton<Foo>
{
public:
Foo()
{
if(pathValue == Paths::PATH_ONE)
myValue = 11;
else if(pathValue == Paths::PATH_TWO)
myValue = 22;
}
int myValue;
};
Then when using an object I could do something like this:
assert(11 == Foo<Paths::PATH_ONE>::Instance().myValue);
To be explicit, Instance() is what will create the object.
Does what I'm trying to do have a name? Is there a part of Boost or C++11 that can help me out?
Thanks!