Topic: friend function defined in class inline?
Author: Joerg Barfurth <jbarfurth@vossnet.de>
Date: 1999/06/13 Raw View
Siemel Naran wrote:
> =
> Member functions defined in the class are inline, even if they lack the=
> 'inline' keyword. Are friend functions defined in the class inline too=
,
> though they lack the keyword?
> =
> struct X {
> X() { } // is inline
> friend X operator+(X x) { return x; } // is this inline?
> };
IMHO Yes.
=46rom 7.1.2 [dcl.fct.spec] paragraph 3:
"A function defined within a class definition is an inline function."
There is no restriction to _member_ functions here.
Also even more explicitly from 11.4 [class.friend] p.5 (irrelevant parts =
snipped):
"A function can be defined in a friend declaration of a class ... Such a
function is implicitly inline."
-- J=F6rg Barfurth
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: sbnaran@localhost.localdomain (Siemel Naran)
Date: 1999/06/12 Raw View
Member functions defined in the class are inline, even if they lack the
'inline' keyword. Are friend functions defined in the class inline too,
though they lack the keyword?
struct X {
X() { } // is inline
friend X operator+(X x) { return x; } // is this inline?
};
--
----------------------------------
Siemel B. Naran (sbnaran@uiuc.edu)
----------------------------------
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]
Author: Biju Thomas <b_thomas@ibm.net>
Date: 1999/06/12 Raw View
Siemel Naran wrote:
>
> Member functions defined in the class are inline, even if they lack the
> 'inline' keyword. Are friend functions defined in the class inline too,
> though they lack the keyword?
>
> struct X {
> X() { } // is inline
> friend X operator+(X x) { return x; } // is this inline?
> };
>
Yes, they are implicitly inline. See 11.4 para 5 in the standard.
--
Biju Thomas
---
[ 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://reality.sgi.com/austern_mti/std-c++/faq.html ]