I have a long template function declaration:
template <typename T> void foo(lots ofargs, goin here, andeven more, ofthese arguments, they just, dont stop);
without overloads. and I want to explicitly create an instance. I can write (say for T = int ):
template void foo<int>(lots ofargs, goin here, andeven more, ofthese arguments, they just, dont stop);
But I really don't want to copy this long ad. I would like to say something like:
template <typename T> using bar = decltype(foo<T>);
and then:
template bar<int>;
Now the first line compiles (GCC 4.9.3), but the second line does not work. Can I make it work? Or can I use decltype() some other way to avoid copying the declaration to instantiate?
Note. I basically used an example in which you cannot infer a type from arguments alone, since I want any solution to support this case as well.
source share