I'm wondering whether it's possible to implement an "interface"'s function via member function templates like so:
struct VisitorI
{
virtual void Visit(int) = 0;
virtual void Visit(float) = 0;
};
struct VisitorC : public VisitorI
{
template<class T>
void Visit(T) { /*Assume Visit(T) has syntatically the same implemenation for each relevant T */}
};
template void VisitorC::Visit(int);
template void VisitorC::Visit(float);
int main()
{
VisitorC Visitor;
return 0;
}
The above code doesn't compile because foo(int) and foo(float) are considered pure virtual in VisitorC, so I'm thinking it's not possible. I don't really see any particular reason why it shouldn't though...?
Cheers, Damian