Re: VS: operator <<(...const std::string&) does not call ->rdbuf()

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Paul wrote:
"Victor Bazarov" wrote:

Paul wrote:
As I understand from the C++ Standard, operator

std::ostream& operator <<(std::ostream& os, const std::string& s);

should call os.rdbuf()->sputn()
I don't see the Standard saying that it "should". I see "inserts characters as if by calling os.rdbuf()->sputn", nothing about "should" or "shall" or some other requirement.

But to me this is as good as saying that the effect should be as if "os.rdbuf()->sputn(str.data(), n)" is called and not ->sputc().
[..]

Maybe there is a defect in the Standard, or a defect in Dinkumware's implementation (based on their interpretation). What would be the [observable] difference between calling 'sputn' and 'sputc' (repeatedly)? I'm guessing you need your virtual function called (as specified in the behaviour of 'sputn')

If you think it's a defect in the implementation, contact Dinkumware or Microsoft and see what they have to say about that. If you think it's a defect in the Standard (and the expected wording needs to be stronger), post to 'comp.std.c++'.

Is there a different approach available to you? 'sputc' is specified to check the availability of the room in the buffer using the pointers (xnext and xend), and call 'overflow' where you're supposed to dump the characters (send or whatever), and change the pointers (not sure what the right code is). What book are you reading, BTW? I remember hearing that Angelika Langer's "Standard C++ Iostreams" was very good. Also, Josuttis' C++ Standard Library book is highly praised.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.



Relevant Pages

  • Javac-compilor error
    ... discipline id.e.programming Java. ... from standard input and writes to standard output, but it is possible to redirect the input ... error occurs while trying to open the file, an exception of type IllegalArgumentException ... then this number of characters, then extra spaces are added to the front of x to bring ...
    (Fedora)
  • Re: Case-sensitivity as option?
    ... Wide characters: Mapped to half-width characters ... I guess taking case insensitivity out of standard would be the right ... simplification (eg. you can use general purpose hash-algorithms ...
    (comp.lang.forth)
  • Re: keyword capitalization -- current practice
    ... outside the scope of the standard. ... more) different characters to be functionally the same. ... I once used a computer that used the ASCII character set, ... But the fortran compiler on that machine only recognized the subset ...
    (comp.lang.fortran)
  • Re: Invariant with DIGIT-CHAR-P and the reader.
    ... should appear to the Lisp reader as a number. ... >>> reading of the standard makes me believe the Lisp reader should ... >> Why a new CL could not accept more forms for unicode digits? ... > a..z, characters chosen by the implementation, and not from some higher ...
    (comp.lang.lisp)
  • Re: array processing in Lisp
    ... use of symbols instead of english for functions ... or dyadically because this depends on its position in a verb train and whether ... * Allow all combinations of printable ASCII characters as symbols, ... ;; in standard J (see ...
    (comp.lang.lisp)