C++ How to make base class template function visible for derived class instances without casting or duplicating signature?

  c++, templates

Hi 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:
    template <class T> void quux() { ... }
};

class Bar : public Foo
{
};

Then later on usage of class Bar:

Bar bar;
bar.quux<int>();                    // ERROR method not found
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.

Source: Windows Questions C++

LEAVE A COMMENT