
"Martin Bonner" <Martin.Bonner@pi-shurlok.com> wrote in news:5D8503D66B71984E8D7F6651BA74D059414E49@yew.PS.LOCAL:
From: Martin Bonner
From: Peter Dimov Sent: Thu 31/05/2007 18:04
Hartmut Kaiser wrote:
You need to add an explicit 'inline' specifier to any function defined out of class but in a header, regardless if it's a templatized function or not.
I don't think that this is true.
Why don't you think this is true?
If you have the same function defined in two translation units (because it is dragged into both via #include), it's a violation of the One Definition Rule unless the definitions have inline.
Apologies for the crap quoting - blame Exchange Webmail
OK. I've fixed the crap quoting. Now it's time to apologize for the crap content. Specifically, section 3.2 [one definition rule] paragraph 5 says:
"There can be more than one definition of a ... non-static function template ... in a program provided that each definition appears in a different translation unit, and provided the definitions satisfy the following requirements."
(The requirements are met by a definition dragged into two translation units via #include.)
In other words Peter is right; you don't need to declare a function template as "inline". If you do, the only effect may be to encourage the compiler to inline it.
Thanks. Andy.