🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #2880

Re: Array Initialization

#2880
From: Joe Buck
Date: Thu, 07 Dec 1995 20:33
46 lines
2730 bytes
Nathan Myers <ncm@netcom.com> writes:
>>>....  The feeling in the committee was that that would be too close to
>>>vector<>.  I.e. when you think you want an auto_array_ptr, consider using
>>>a vector<> instead.  

John Max Skaller <maxtal@suphys.physics.su.oz.au> writes:
>>In my humble opinion, this is a mistake; vector<> is a far bigger chunk of
>>code than auto_array_ptr<> and supports functionality beyond what a natural
>>auto_array_ptr would supply.

jbuck@Synopsys.COM (Joe Buck) wrote:
>Actually, this need not be the case. If you _use_ a vector
>"as if" it were a less kind of array type, the code
>for the "extra" functionality won't be generated.

Rather, *some* of the code won't be generated.  In practice, you're
getting code and data you don't need, that slows down compilation
and occupies memory, because vectors must support the push_back
functionality (they need to grow).  auto_array_ptr<>, on the other
hand, doesn't impose such costs.

>Remember vector isn't really a template, it's a built in 
>structuring tool of the C++ language just like 
>"array" or "struct" is.

I'm not buying it, John.  That's just like saying stdio.h isn't really a
header file, since it's standard and C implementations could do various
kinds of magic when they see the string '#include <stdio.h>'.  But in
practice we still get compilers that work in the natural way.  And in
practice, vector is going to be a template for the next several years at
least.

>Don't expect this kind of optimisation right away -- 
>we need stable working ISO C++ implementations first.

Don't expect this kind of optimization for many years to come.
In any case, I'd advise against it: special-casing STL for improved
performance would mean templates stay inefficient.

-- 
-- Joe Buck 	<jbuck@synopsys.com>	(not speaking for Synopsys, Inc)


[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  The moderation policy
  is summarized in http://dogbert.lbl.gov/~matt/std-c++/policy.html. ]
Technical Details
Message-ID: <4a7grh$31f@hermes.synopsys.com>
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
References: <30B1CB7E.41C67EA6@ecid.cig.mot.com> <30BA28C5.50C6@netcom.com> <49gb4c$h5o@hermes.synopsys.com> <4a4cfq$sp8@oznet03.ozemail.com.au>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!engnews1.Eng.Sun.COM!taumet!clamage
From: jbuck@Synopsys.COM (Joe Buck)
Newsgroups: comp.std.c++
Subject: Re: Array Initialization
Date: 7 Dec 1995 20:33:08 GMT
Organization: Synopsys Inc., Mountain View, CA 94043-4033
Approved: clamage@eng.sun.com (comp.std.c++)
Message-ID: <4a7grh$31f@hermes.synopsys.com>
References: <30B1CB7E.41C67EA6@ecid.cig.mot.com> <30BA28C5.50C6@netcom.com> <49gb4c$h5o@hermes.synopsys.com> <4a4cfq$sp8@oznet03.ozemail.com.au>
NNTP-Posting-Host: taumet.eng.sun.com
Content-Type: text
X-Nntp-Posting-Host: deerslayer.synopsys.com
Content-Length: 1827
X-Lines: 42
Originator: clamage@taumet