From 6016017452446980407
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,cc1a555bbe9617a3
X-Google-Attributes: gidf78e5,public
From: "Bill Wade" <bill.wade@stoner.com>
Subject: Re: STL and SGI and strings
Date: 1998/01/14
Message-ID: <69igmc$3gq$1@uuneo.neosoft.com>#1/1
X-Deja-AN: 316060437
References: <34B57837.41C6@pixar.com> <34B6580F.6A50@pratique.fr> <m3oh1jezw9.fsf@gabi-soft.fr> <34BAA6FB.17121A3E@acm.org> <34BB973F.167EB0E7@pratique.fr>
X-Original-Date: Wed, 14 Jan 1998 08:04:58 -0600
Originator: austern@isolde.mti.sgi.com
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4
Organization: NeoSoft, Inc.
X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBNL1+XUy4NqrwXLNJAQF7hAH/Z7Nu41DTd30dN/24X4kFcsVQ+DebWHWz HvNg4ftqoUMqRo1uBCIfy7NCKJbkv35Qt3QyRGyXU4pbzn0o5WpXrw== =Wlav
Newsgroups: comp.std.c++


Valentin Bonnard wrote in message <34BB973F.167EB0E7@pratique.fr>...
>> J. Kanze wrote:
>> >
>> > In my own code, I don't think I've
>> > ever used an op[], either in my own string class or someone elses.
I'll
>> > admit that I cheat, however -- when parsing, I normally do the
>> > equivalent of c_str(), and use the resulting pointer:-).
>
>Which still disallow sharing, except if c_str copies the data, which
>is as inneficient.

Why does c_str() disallow sharing?  It returns a pointer to const which
remains valid only until a non-const member of the string is called.

Given
  string a,b("Hello");
  a=b;
  const char* pa = a.c_str();
  const char* pb = b.c_str();
I don't see any requirement that pa!=pb.

>In particular, how does one reaad the char at position i ?


a.c_str()[i]
---
[ comp.std.c++ is moderated.  To submit articles: Try just posting with your 
                newsreader.  If that fails, use mailto:std-c++@ncar.ucar.edu
  comp.std.c++ FAQ: http://reality.sgi.com/austern/std-c++/faq.html
  Moderation policy: http://reality.sgi.com/austern/std-c++/policy.html
  Comments? mailto:std-c++-request@ncar.ucar.edu 
]



