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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Thread: 109fba,703c4f68db81387d X-Google-Thread: 115aec,703c4f68db81387d X-Google-Thread: f43e6,703c4f68db81387d X-Google-Attributes: gid103376,gid109fba,gid115aec,gidf43e6,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!proxad.net!fr.ip.ndsoftware.net!newsfeed.freenet.de!151.189.20.20.MISMATCH!newsfeed.arcor.de!news.arcor.de!not-for-mail Date: Thu, 10 Mar 2005 12:29:03 +0100 From: Georg Bauhaus User-Agent: Debian Thunderbird 1.0 (X11/20050116) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada,comp.lang.c++,comp.realtime,comp.software-eng Subject: Re: Teaching new tricks to an old dog (C++ -->Ada) References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <1110032222.447846.167060@g14g2000cwa.googlegroups.com> <871xau9nlh.fsf@insalien.org> <3SjWd.103128$Vf.3969241@news000.worldonline.dk> <87r7iu85lf.fsf@insalien.org> <87is4598pm.fsf@insalien.org> <1110054476.533590@athnrd02> <1110059861.560004@athnrd02> <422b6d49.1141887367@news.xs4all.nl> <1110266099.441421.179290@o13g2000cwo.googlegroups.com> <1110332933.587110.260410@z14g2000cwz.googlegroups.com> <1110390097.532139.43430@f14g2000cwb.googlegroups.com> <422f3808$0$30165$ba620e4c@news.skynet.be> <1110409958.685759.249420@g14g2000cwa.googlegroups.com> <1110422853.41859@athnrd02> In-Reply-To: <1110422853.41859@athnrd02> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <42302f4d$0$26544$9b4e6d93@newsread4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 10 Mar 2005 12:28:13 MET NNTP-Posting-Host: 6717834a.newsread4.arcor-online.net X-Trace: DXC=cZ3`LH_2`jKO@oM:dhE>=@:ejgIfPPldDjW\KbG]kaMHGSi?jHD8GO@0EoDC;aOUADhP3YJKgE\jL:` Ioannis Vranos wrote: > For example consider this simple bullet-proof code for string input and > processing: > > > #include > #include > > int main() > { > using namespace std; > > string s; > > while(cin) > { > getline(cin,s); > > /*Do things with s */; > } > } When I run your program and have it read the null device, it stops after reading 536870883 bytes if s.length() is right. This number is 29 bytes less than 2^29; however, s.max_size() is printed as 1073741820, which is 4 bytes less than 2^30. There is 1G of memory in the system. Is this an implementation detail/system specific? I'm not now expecting a compiler for any language to read past 512M, but I'd like to know what is going on. I noticed size_type max_size () const { return (npos - 1)/sizeof (charT); } // XXX in the header file for string, the XXX is in the original.