I'm trying to specialize a static template function from a base class, and figured this was a good use case for a typedef/using statement. I can't seem to get it to work, though. Is this illegal, or is my syntax wrong?
#include <iostream>
class Base {
public:
template <typename T>
static T func () {
std::cout << (T)3.145 << std::endl;
}
};
class Derived : public Base {
public:
// using derivedFunc = Base::func<int>; // This doesn't work
// typedef Base::func<int> derivedFunc; // Nor this
static constexpr auto derivedFunc = &Base::func<int>; // But this seems to work
};
int main() {
Base::func<double>(); // Prints 3.145
Derived::derivedFunc(); // Prints 3
return 0;
}