Reputation: 604
I want to have a class that is accessible with and without template parameters. See the example below. I did some research but didn't find anything helpful, except template specialization but that is not what I want.
class Execute
{
...
}
template<class T>
class Execute
{
...
}
I want to be able to create objects of these classes like:
Execute exec1;
Execute<int> exec1;
Does anyone have an idea on how to achieve this? I did several setups but none did succeed.
Upvotes: 0
Views: 74
Reputation: 41301
Not exactly what you want, but you can specify a default template argument:
template<class T = void>
class Execute
{
};
template<>
class Execute<void>
{
};
Execute<> exec1; // Instantiates Execute<void>
Execute<int> exec2;
Upvotes: 3