Topic: Can a conforming implementation define inline member functions for standard containers?
Author: Alan Johnson <awjcs@yahoo.com>
Date: Tue, 23 Jun 2009 10:18:00 CST Raw View
Section 23.2.4 contains the class template definition for vector. None
of the member functions are defined within this class definition. Also,
none of the specifications for any of the member functions says anything
about them being inline.
Can we correctly conclude, then, that any implementation that defines
vector's member functions within the class template definition (or
otherwise makes them inline) is not conforming?
Thanks.
--
Alan Johnson
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Pete Becker <pete@versatilecoding.com>
Date: Tue, 23 Jun 2009 11:39:44 CST Raw View
Alan Johnson wrote:
> Section 23.2.4 contains the class template definition for vector. None
> of the member functions are defined within this class definition. Also,
> none of the specifications for any of the member functions says anything
> about them being inline.
>
> Can we correctly conclude, then, that any implementation that defines
> vector's member functions within the class template definition (or
> otherwise makes them inline) is not conforming?
>
Can you write a conforming program that can tell the difference?
--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: usenet@mkarcher.dialup.fu-berlin.de (Michael Karcher)
Date: Tue, 23 Jun 2009 11:40:21 CST Raw View
Alan Johnson <awjcs@yahoo.com> wrote:
> Can we correctly conclude, then, that any implementation that defines
> vector's member functions within the class template definition (or
> otherwise makes them inline) is not conforming?
Can you write a conforming test program that determines during compile
time or during run time whether the implementation of the vector member
function is inline? I can not think of any, and in that case, making
these functions inline is allowed by the as-if rule, stating that the
implementation does not have to do everything as specified in the
standard as long as no conforming program can detect the difference.
Casting function pointers to data pointers to do runtime analysis of
the generated code to find out whether the vector functions are inlined
is possible, and you probably will manage to write such a program for
your platform. But the program will need to use expressions with
unspecified or (even worse) undefined behaviour (most notably: the cast
I mentioned at the beginning of this paragraph), so it will not be a
"conforming" program.
Regards,
Michael Karcher
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: Greg Herlihy <greghe@mac.com>
Date: Wed, 24 Jun 2009 17:29:19 CST Raw View
On Jun 23, 9:18 am, Alan Johnson <aw...@yahoo.com> wrote:
> Section 23.2.4 contains the class template definition for vector. None
> of the member functions are defined within this class definition. Also,
> none of the specifications for any of the member functions says anything
> about them being inline.
>
> Can we correctly conclude, then, that any implementation that defines
> vector's member functions within the class template definition (or
> otherwise makes them inline) is not conforming?
No. For one, an inline member function does not need to be declared
"inline" within its class definition. So the fact that a particular
std::vector member function is not declared inline within the
std::vector class template definition - does not mean that that member
function may not be declared inline later on.
For another, the C++ Standard expressly allows Standard Libtary
classes to have inline member functions:
"It is unspecified whether any member functions in the C++ Standard
Library are defined as inline."[ 17.4.4.4/1]
Greg
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
Author: James Kanze <james.kanze@gmail.com>
Date: Wed, 24 Jun 2009 17:29:45 CST Raw View
On Jun 23, 7:40 pm, use...@mkarcher.dialup.fu-berlin.de (Michael
Karcher) wrote:
> Alan Johnson <aw...@yahoo.com> wrote:
> > Can we correctly conclude, then, that any implementation
> > that defines vector's member functions within the class
> > template definition (or otherwise makes them inline) is not
> > conforming?
> Can you write a conforming test program that determines during
> compile time or during run time whether the implementation of
> the vector member function is inline? I can not think of any,
> and in that case, making these functions inline is allowed by
> the as-if rule, stating that the implementation does not have
> to do everything as specified in the standard as long as no
> conforming program can detect the difference.
> Casting function pointers to data pointers to do runtime
> analysis of the generated code to find out whether the vector
> functions are inlined is possible,
I don't see how? As soon as you take the address of a function
(inline or not), you'll get an out-of-line copy of it in the
program.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S mard, 78210 St.-Cyr-l' cole, France, +33 (0)1 30 23 00 34
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]