home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c++.moderated      Moderated discussion of C++ superhackery      33,346 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 32,071 of 33,346   
   =?ISO-8859-1?Q?Daniel_Kr=FCgler?= to Pete Becker   
   Re: Modification of trailing null charac   
   30 Mar 12 01:35:57   
   
   From: daniel.kruegler@googlemail.com   
      
   On 2012-03-30 05:51, Pete Becker wrote:   
   > On 2012-03-29 21:05:40 +0000, Nikolay Ivchenkov said:   
   >   
   >> On 29 Mar, 23:13, Seungbeom Kim  wrote:   
   >>> Therefore, I think an implementation   
   >>> that doesn't keep a null character at the end is making things difficult   
   >>> for itself for no good reason I can see.   
   >>   
   >> Such implementations of basic_string are disallowed under C++11 rules   
   >> - see 21.4.7.1/1.   
   >   
   > Not really. c_str() can return a pointer to a newly-allocated array   
   > that holds a copy of the data, with a terminating 0. Sigh.   
      
   Only in C++03.   
      
   > But I vaguely recall that there was a change for C++11 that did   
   > disallow this kind of thing, but it's not coming to mind at the moment.   
      
   This is correct, in C++11 this has changed, both data() and c_str() are   
   now noexcept functions and *both* are required to return a pointer to a   
   null-terminated string.   
      
   Greetings from Bremen,   
      
   Daniel Krügler   
      
      
   --   
         [ See http://www.gotw.ca/resources/clcm.htm for info about ]   
         [ comp.lang.c++.moderated.    First time posters: Do this! ]   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca