Article View: comp.std.c++
Article #3273Re: basic_string& operator=(const basic_string&
From: Paul Newson
Date: Wed, 07 Feb 1996 00:47
Date: Wed, 07 Feb 1996 00:47
48 lines
2878 bytes
2878 bytes
>The following was taken from a copy of the DWP: > > basic_string<charT,traits,Allocator>& > operator=(const basic_string<charT,traits,Allocator>& str); > > Effects: > If *this and str are not the same object, modifies *this such that: > > Table 7--operator=(str) effects > > +-------------------------------------------------+ > | Element Value | > +-------------------------------------------------+ > |data() points at the first element of an | > | allocated copy of the the array | > | whose first element is pointed at | > | by str.size() | > |size() str.size() | > |capacity() a value at least as large as size() | > +-------------------------------------------------+ > If *this and str are the same object, the member has no effect. > Returns: > *this > >Aside from a seeming typographical error in the Value column for Element data() >(... by str.data() ?) the wording of this seems to rule out a counted pointer >representation. > >Is my interpretation correct? > >-- >John Hickin Bell-Northern Research, Montreal, Quebec >(514) 765-7924 hickin@bnr.ca >--- Because str.data() is a member function, a counted pointer implementation of the string class could perform a copy on write at the time of the call to str.data(). Member functions to return constant iterators, for example, need not cause the string to be copied, so a counted pointer implementation of the string class could still be written. (At least, the definition of str.data() does not rule it out, there might be something else that does.) Paul Newson penewson@novice.uwaterloo.ca --- [ comp.std.c++ is moderated. Submission address: std-c++@ncar.ucar.edu. Contact address: std-c++-request@ncar.ucar.edu. The moderation policy is in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Technical Details
Message-ID:
<199602062335.SAA13298@novice.uwaterloo.ca>Path:
arc1-ca.pugleaf.net!fido.asd.sgi.com!austernShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!fido.asd.sgi.com!austern From: penewson@novice.uwaterloo.ca (Paul Newson) Newsgroups: comp.std.c++ Subject: Re: basic_string& operator=(const basic_string& Date: 06 Feb 1996 16:47:26 PST Organization: - Approved: austern@isolde.mti.sgi.com Message-ID: <199602062335.SAA13298@novice.uwaterloo.ca> NNTP-Posting-Host: isolde.mti.sgi.com Content-Type: text/plain; charset="us-ascii" X-Original-Date: Tue, 06 Feb 1996 18:36:06 -0500 X-Sender: penewson@novice.uwaterloo.ca X-Mailer: Windows Eudora Version 1.4.4 X-Auth: PGPMoose V1.1 PGP comp.std.c++ iQBVAwUBMRf23Uy4NqrwXLNJAQEs3wIAtbk0XDibeEqZjIITc+dNLrgDh74h6Ost 9uEOEvqGlBLkdiEIzexRjed38yqve3wt32X5aNd8Q0vubm602nTNPw== =NZ8J Originator: austern@isolde.mti.sgi.com