Topic: Are inline function templates supposed to work?


Author: fjh@munta.cs.mu.OZ.AU (Fergus Henderson)
Date: Fri, 8 Apr 1994 13:50:45 GMT
Raw View
tkorvola@dopey.hut.fi (Timo Korvola) writes:

>Is the following code supposed to be valid C++?

Good question.  I've redirected it to a more appropriate group.
Hopefully someone in comp.std.c++ will be able to help.

>inline void foo( int &x) {}
>
>template <class type>
>inline void foo( type &x) {x.eat_this_and_die();}
>
>int main( int argc, char **argv) {foo( argc);}

[... g++ rejects this code, with a confusing diagnostic ...]

>Is it forbidden to use "inline" with a function template?  I tried to
>look this up in ARM but didn't find an answer.
>
>I've also tried to compile the code with some commercial compilers,
>which compiled it without essential warnings (typically warning about
>unused arguments & no return value from main).
>
>If "inline" is removed from the template, gcc compiles the example.

--
Fergus Henderson - fjh@munta.cs.mu.oz.au