I want to use the base class template function, for example:
struct A {
template <class T> static auto f() { \*code*\ }
};
template <class A_type> struct B : public A_type {
using A_type::f;
void g() { auto n = f<int>(); }
};
However, this does not compile.
error: expected '(' for function-style cast or type
construction
void g() { auto n = f<int>(); }
~~~^
error: expected expression
void g() { auto n = f<int>(); }
But the link to the base class directly, and not to the template, works:
struct A {
template <class T> static auto f() { \*code*\ }
};
template <class A_type> struct B : public A_type {
using A::f;
void g() { auto n = f<int>(); }
};
Why the first version does not compile, and the second does. And what do I need to do differently to make it work?
source
share