Re: Template friend function injection
H9XLrv5oXVNvHiUI@spambox.us wrote:
[..]
So does it mean that my syntax of function injection is standard-
compliant? And do you know of a way to accomplish the same thing
within the template class?
From all I could gather by reading the Standard and other posts, there
is nothing wrong with your code even when the template is involved.
[temp.friend]/5 says:
<quote>
When a function is defined in a friend function declaration in a class
template, the function is defined at each instantiation of the class
template. The function is defined even if it is never used. The same
restrictions on multiple declarations and definitions which apply to
non-template function declarations and definitions also apply to these
implicit definitions.
</quote>
The function is inline (implicitly), it's defined (per that paragraph)
when you instantiate your template.
VC++ 9 (Visual Studio 2008) chokes on the module throwing C1001 (ICE) on
the line that contains the friend declaration. Why, I don't know. I do
not know whether it's been already reported as a bug, either. I'll ask
in the Visual C++ newsgroup. As for GCC, you would have to ask them.
Comeau C++ (online) compiles it fine; it doesn't link, so I am not sure
if everything's OK with their ability to handle that code.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask