Although the explicit templates are working for me, there is a question
about this that bothers me:
Why do we need a special
template function forward declaration?
1 2 3 4
|
template< class T >
T f( T t );
extern template int f( int );
|
Instead of the above four lines of code,
why not just the standard single-line, non-template, function forward declaration:
After all, the symbol generated by the template mechanism has the same signature, and,
I assume, the same argument passing semantics as a symbol generated by
a non-template function definition. What does it matter whether or not
it was generated by a template mechanism?
This is more than an aesthetics issue. Having the
template forward declaration
1 2
|
template< class T >
T f( T t );
|
introduces the chance of ambiguous/extraneous template matching. I have had to mildly
re-juggle my code and convert some template instantiation to less elegant non-template
instantiation.