É possível ter uma classe com um parâmetro de template opcional que possa ser chamado assim?:
#include <iostream>
template <typename T = void>
class A final
{
public:
// This class can be called only when T exists.
void f()
{
printf("%d\n", member);
}
// This method can be called only when T is missing.
void g()
{
printf("No template parameter\n");
}
public:
T member;
};
int main()
{
A<int> a1;
A a2;
a1.f(); // should be valid
a1.g(); // should be invalid, cannot compile
a2.f(); // should be invalid, cannot compile
a2.g(); // should be valid
return 0;
}
Se sim, quais são as funções padrão que devem ser usadas?