Mail Archives: djgpp/1995/03/16/15:34:42
On Thu, 16 Mar 1995, Erik Laumb Jensen wrote:
>
> test.cc: In function `int main()':
> test.cc:1: warning: can't inline call to `void tSwap(int &,int &)'
> Am I missing something here? I know that the 'inline' keyword is a request
> only, but if template functions can't be inlined (where the equivalent
> non-template function can), I'd just as well write macros. As I
Current version of g++ can't inline template functions on their *first* use.
This is a limitation, and is caused by the fact that the template function
is instantiated at that point.
To get around this, just add an explicit instantiation directive to your
file,
template void tSwap(int&, int&);
or something like that. This will cause the template to be instantiated
at that point, so that it can be expanded inline when it is actually used.
--
Gordon J. Hogenson <ghogenso AT u DOT washington DOT edu> Tel. (206) 685-2951
- Raw text -