Topic: inline or not inline?


Author: "Gennaro Prota" <gennaro_prota@my-deja.com>
Date: Wed, 23 May 2001 15:07:50 GMT
Raw View
"Martin Aupperle" <MikeAlpha@NoSpam_csi.com> wrote in message
news:3b02a2fa.76957619@news.nikoma.de...
> Hello,
>
> we recently came across the question whether f is inline or not, given
> the following construct;
>
> class X
> {
>   friend void f() { cout << "in f"; }
> };
>
> I know that this would be the case if f were a member function. But it
> is a global function.
>
> Martin

If the definition is allowed "within" the class declaration, the function is
inline, as stated in    11.4, bullet 5 of the standard:

"A function can be defined in a friend declaration of a class if and only if
the class is a non-local class (9.8), the function name is unqualified, and
the function has namespace scope. [snip...] Such a function is implicitly
inline."



Gennaro.


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]





Author: MikeAlpha@NoSpam_csi.com (Martin Aupperle)
Date: Wed, 23 May 2001 09:34:54 GMT
Raw View
Hello,

we recently came across the question whether f is inline or not, given
the following construct;

class X
{
  friend void f() { cout << "in f"; }
};

I know that this would be the case if f were a member function. But it
is a global function.

Martin

------------------------------------------------
Martin Aupperle
MikeAlpha@NoSpam_csi.com
(remove NoSpam_)
------------------------------------------------

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html                ]