Topic: char_traits<T> return values


Author: Rich Paul <linguist@cyberspy.com>
Date: 1996/04/12
Raw View
I have noticed, while working on the standard string class, that the
char_traits functions copy, move, etc, would be much more useful if they
returned a pointer to the END of the area in which they worked, rather
than to the beginning.

I know c liked to return the pointers you gave it when it was done with
them, but isn't there something more useful that could be done?

Also, when these functions get a string that contains eos(), do they
stop, or do they carry on to the bitter end?

--
#include <legalbs/standarddisclaimer>
Rich Paul                |  If you like what I say, tell my
C++, OOD, OOA, OOP,      |  employer, but if you don't,
OOPs, I forgot one ...   |  don't blame them.  ;->


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: "Nathan Myers <ncm@cantrip.org>" <ncm@cantrip.org>
Date: 1996/04/13
Raw View
Rich Paul wrote:
> I have noticed, while working on the standard string class, that the
> char_traits functions ...
> ... when these functions get a string that contains eos(), do they
> stop, or do they carry on to the bitter end?

C++ strings don't pass judgment on what's in them; eos() is used
purely as the value to slap onto the end when producing a c_str()
value, or the terminator when constructing from a const char*.

It only matters when you convert back via c_str(); then, of course,
to C the string will look shorter than it is.  Tough.

Nathan Myers
ncm@cantrip.org  http://www.cantrip.org/


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: Rich Paul <linguist@cyberspy.com>
Date: 1996/04/15
Raw View
Nathan Myers <ncm@cantrip.org> wrote:
> It only matters when you convert back via c_str(); then, of course,
> to C the string will look shorter than it is.  Tough.

Aha ... well, that solves the length cacheing problem ... given
that operator[] could insert an eos() I've been avoiding keeping
track of string length ... well that's a wrinkle.

Thanks alot fo the input!
---
[ 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
]