Reputation: 64895
Can I give a specific instantiation of a template function a name, so it can be called a like a non-template function?
E.g.,
// some template function
template <typename T>
void foo(T t) {...}
// I would like int_foo to behave like a regular function with
// foo<int> as its implementation (obviously this doesn't compile because
// using cannot be used like this)
using int_foo = foo<int>;
One way is to just delegate and rely on inlining to do the rest, like:
void int_foo(int i) {
foo<int>(i);
}
... but if there is a more direct way I'm all ears.
Upvotes: 1
Views: 28
Reputation: 275350
No, there is not, which does not require 30 characters, but all answers do.
Upvotes: 2