Is there any way to avoid cast when calling a base class template function from a derived class instance? Suppose the following:
class Foo
{
public:
virtual void quux() = 0;
template <class T> void quux() { ... }
};
class Bar : public Foo
{
public:
void quux() override {}
};
Then later on usage of class Bar
:
Bar bar;
bar.quux<int>(); // error: type 'int' unexpected
static_cast<Foo&>(bar).quux<int>(); // OK
Any way to make this less obnoxious and make function quux
callable on instances of Bar
without having to duplicate the function signatures directly in Bar
implementation? I'm aware of dependent name lookup, looking for a maintainable way to solve this for all derived classes.
CodePudding user response:
Just add using Foo::quux;
:
class Bar : public Foo
{
public:
using Foo::quux;
void quux() override {}
};