I think I've encountered a problem beyond my template metaprogramming skills...
Here's the deal: I need to choose a constructor (preferrablly at compile time) based upon an argument to my template.
That pretty much summarizes it. I think that code would work. The catch? I can't use partial template specialization, as my compiler doesn't support it. Is there any way around this?
I do have complete control of all code in question, and thus could modify the design to use member functions to set the additional parameter, for example, but I'd rather not.
Here's the deal: I need to choose a constructor (preferrablly at compile time) based upon an argument to my template.
Code:
class Example1
{
Example1(int a);
};
class Example2
{
Example2(int a, bool b);
};
typedef struct{} tagConstructorInt;
typedef struct{} tagConstructorIntBool;
template<class Type, class Tag> class Creator
{
Type* Create();
};
template<class Type> Type* Creator<Type, tagConstructorInt>::Create()
{
return new Type(500);
}
template<class Type> Type* Creator<Type, tagConstructorIntBool>::Create()
{
return new Type(500, true);
}
I do have complete control of all code in question, and thus could modify the design to use member functions to set the additional parameter, for example, but I'd rather not.