Topic: basic_ios::copyfmt(), has bug?
Author: sorry@but.spammed.out (Howard Hinnant)
Date: 1998/03/08 Raw View
Hi,
I am concerned that the copyfmt() routine in basic_ios may have a bug in
its specification. The specification is:
<quote>
basic_ios& copyfmt(const basic_ios& rhs);
Effects:
Assigns to the member objects of *this the corresponding member
objects of rhs, except that:
--rdstate() and rdbuf() are left unchanged;
--exceptions() is altered last by calling exceptions(rhs.except).
--The contents of arrays pointed at by pword and iword are copied not
the pointers themselves.8)
1 If any newly stored pointer values in *this point at objects stored
outside the object rhs, and those objects are destroyed when rhs is
destroyed, the newly stored pointer values are altered to point at
newly constructed copies of the objects.
2 Before copying any parts of rhs, calls each registered callback pair
(fn,index) as (*fn)(erase_event,*this,index). After all parts but
exceptions() have been replaced, calls each callback pair that was
copied from rhs as (*fn)(copy_event,*this,index).
Notes:
The second pass permits a copied pword value to be zeroed, or its
referent deep copied or reference counted or have other special
action taken.
Returns:
*this.
<end quote>
If I'm not mistaken, the intent is to copy the format information from rhs
to *this, but not the stream (and associated info).
According to the spec above, the information that tie() returns is
copied. This means that copyfmt() will change format information, but not
the actual rdbuf, BUT it will change what the rdbuf is tied too! I am not
an I/O expert, but that just seems too weird. Is this intentional?
By the way, copy_event is misspelled in the spec.
Thanks,
-Howard
---
[ 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 ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html ]