🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Paul Newson Wed, 07 Feb 1996 00:47
Re: basic_string& operator=(const basic_string&
#3273
Author: Paul Newson
Date: Wed, 07 Feb 1996 00:47
48 lines
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. ]
Re: basic_string& operator=(const basic_string&
#3299
Author: Steve Clamage
Date: Wed, 07 Feb 1996 15:57
25 lines
1687 bytes
My original posting was somewhat ill-posed.  What I really meant to say
was that it seems to me that a counted pointer representation is to ruled
out in practice because the DWP wording, in my opinion, prevents the
representation to be shared in the only case that makes sense to share.

I interpret the phrase

	 points at the first element  of  an
	 allocated  copy  of  the  the array
	 whose first element is  pointed  at
	 by str.data()
                ^^^^<--------- my 'wording' now

as meaning that if we had a string x without sharers then string y(x)
would necessarily create another string without sharers.

-- 
John Hickin      Nortel Technology, Montreal, Quebec
(514) 765-7924   hickin@bnr.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
  summarized in http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
]
Re: basic_string& operator=(const basic_string&
#3298
Author: john (j.d.) hickin
Date: Thu, 08 Feb 1996 10:48
13 lines
1296 bytes
My original posting was not terribly explicit.  My interpretation of the
wording in Table 7 is that an assignment x=y cannot share the string data
of y.  My interpretation of Table 3 for the copy constructor is the same:
string x(y) cannot sahre y's data.  I conclude, therefore, that a counted
pointer representation is allowed in theory but 'prevented in practice'.

-- 
John Hickin      Nortel Technology, Montreal, Quebec
(514) 765-7924   hickin@bnr.ca
---
[ comp.std.c++ is moderated.  Submission address: std-c++@ncar.ucar.edu.
  Contact address: std-c++-request@ncar.ucar.edu.  Moderation policy:
  http://reality.sgi.com/employees/austern_mti/std-c++/policy.html. ]
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads