question regarding basic_stream::imbue

I have a simple question regarding basic_stream::imbue(locale &) Can it be applied after a file is opened? The state saver libray seems to suggest that it can. Some information suggests that it can if the file is position at the start. Experience with dinkumware and STLport suggests that it can't. If it can't what's the best way to work around it? Robert Ramey

Robert Ramey wrote:
I have a simple question regarding basic_stream::imbue(locale &)
Can it be applied after a file is opened?
The state saver libray seems to suggest that it can.
Some information suggests that it can if the file is position at the start.
Well, the standard says that: void imbue(const locale& loc); Precondition: If the file is not positioned at its beginning and the encoding of the current locale as determined by a_codecvt.encoding() is state-dependent, then that facet is the same as the corresponding facet of loc. So the question is whether facet in default-constructed wifstream is state-dependent or not. I've tried the following program with g++ and it prints '0' (not state-dependent). Would be interesting to see what it prints for you. - Volodya
participants (2)
-
Robert Ramey
-
Vladimir Prus