To illustrate:
struct MyFunc {
template <size_t N>
void doIt() {
cout << N << endl;
}
};
template <typename Func>
struct Pass123ToTemplateFunc {
static void pass(Func f) {
f.doIt<123>(); // <-- Error on compile; is there a way to express this?
}
};
int main() {
Pass123ToTemplateFunc<MyFunc>::pass(MyFunc());
return 0;
}
This is pretty much purely a syntax curiosity; is there a way in the language to express this without passing arguments to the doIt
function itself? If not, it's no big deal and I'm already well aware of ways I can gracefully work around it, so no need to provide alternative solutions. (I'll accept "no" as an answer, in other words, if that's the truth. :-P)
You have to tell the compiler that doIt
will be a template:
f.template doIt<123>();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With