Large file iostreams
Pétur Runólfsson
peturr02@ru.is
Thu Sep 4 09:48:00 GMT 2003
Martin Sebor wrote:
> > But it is never specified what is meant by "initialized".
> > I agree that this seems to be a real problem when using codecvt
> > directly.
>
> Not really. Portable code just needs to make sure to zero it out
> before passing it to codecvt. Footnote 226 in 22.2.1.5.2, p5 even
> suggests how it should be done in the generic case -- by assigning
> it stateT().
That footnote says that it is "typically" stateT(). I assume that
the qualification is to allow user-defined stateT that needs some
other mechanism. It says nothing about the specific case of
mbstate_t.
> Yes. And C says it must be zeroed out, e.g., by assigning it
> the value of mbstate_t() or calling memset(0) on it.
That is the initial state for use with the mbrtowc and friends.
Nothing in the C++ standard says that codecvt must be implemented
in terms of the C library (or even that it should support the
same set of encodings), so it doesn't follow that the initial
state must be the same.
Regards,
Petur
More information about the Libstdc++
mailing list