[xsd-users] std::ostream setprecision() causes invalid output for ::xml_schema::date_time

Boris Kolpackov boris at codesynthesis.com
Mon May 11 09:20:18 EDT 2020


Jeroen N. Witmond <jeroennwitmond at gmail.com> writes:

> I'm aware that careless use of setprecision() can be regarded as a user
> error; in that case this message will serve as a warning.

Yes, the only way to fix this in current implementation is to have an
explicit call to setprecision() before (and probably another one after,
to restore the original value) around every floating point value
serialization, which could have a performance impact.

Probably the correct way to fix this is to use C++11 snprintf() (when we
drop support for C++98) or even C++17 to_chars() (that API was made
specifically for these type of "serialization" use-cases).

Thanks for the warning!



More information about the xsd-users mailing list