From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,243dc2fb696a49cd X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed00.sul.t-online.de!newsmm00.sul.t-online.de!t-online.de!news.t-online.com!not-for-mail From: Martin Krischik Newsgroups: comp.lang.ada Subject: Re: Ada Popularity: Comparison of Ada/Charles with C++ STL (and Perl) Date: Thu, 30 Sep 2004 17:55:36 +0200 Organization: AdaCL Message-ID: <548294322.7bjRbCk6U1@linux1.krischik.com> References: <1777528.JKnUEYTOM6@linux1.krischik.com> <1ec946d1.0409230820.455ad242@posting.google.com> <3673998.bj16mkkOu2@linux1.krischik.com> <1700922.2nPlMsa4Ny@linux1.krischik.com> <3750337.aJMmIeXcav@linux1.krischik.com> <3060085.UHp9MgIIe7@linux1.krischik.com> Reply-To: krischik@users.sourceforge.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7Bit X-Trace: news.t-online.com 1096613807 01 9947 epzkXpm6Vpf9V2V 041001 06:56:47 X-Complaints-To: usenet-abuse@t-online.de X-ID: XLpYWqZOgeNoipO3cE1ccsynp189GDLs2LLPQxy86GPQJmOWvuw8o3 User-Agent: KNode/0.8.0 Xref: g2news1.google.com comp.lang.ada:4486 Date: 2004-09-30T17:55:36+02:00 List-Id: Robert Kawulak wrote: >> But that means that the strings need "capacity () - size () >= 1" so that >> there is allways one spare byte for the '\0'. > > Well, in those particular implementations yes, but AFAIK it's not imposed > by the standard. > >> I was thinking about "capacity () - size () == 0" - then c_str() would >> need >> to resize. Doesn't happen in your implementation - but is this valid for >> all. > > As said above, it's not. An implementation can choose freely, but I > suspect that vast majority use "capacity () - size () >= 1" due to > efficiency - after all this one extra byte doesn't cost a lot compared to > creating new buffer for whole the string and copying it in case of a call > to c_str(). Well, since all book I have read state that the pointer is valid until a "non const method" is called there are only two possible implementations left: The "capacity () - size () >= 1" and the "spare buffer/pointer" solution which would keep spearate buffers and/or pointers for different representations. But maybe there are exotic solutions as well. With Regards Martin -- mailto://krischik@users.sourceforge.net http://www.ada.krischik.com