Is it possible to define an interface such as:
class IFoo
{
virtual void foo(const X &x) const = 0;
virtual void foo(X &x) = 0;
};
and define both foo
methods in a subclass C
with a template which can be instantiated twice, once for type argument <const X>
and once for <X>
? e.g something like:
class C : public IFoo
{
template<typename T>
void foo(T &t) {...}
};
// instantiate void C::foo(X &x)
// and void C::foo(const X &x) const ???