]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Use RAII types in strtod-based std::from_chars implementation
authorJonathan Wakely <jwakely@redhat.com>
Thu, 4 May 2023 14:22:07 +0000 (15:22 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Thu, 11 May 2023 20:15:22 +0000 (21:15 +0100)
commitbd02669579fed2617f1090c8640bdcdced1ab7a1
tree6701dc24f0749ce0a576ca4b57d3089dec58318a
parentaa39ed4467db0cf18f300fcf475e09c4496527cf
libstdc++: Use RAII types in strtod-based std::from_chars implementation

This adds auto_locale and auto_ferounding types to use RAII for changing
and restoring the local and floating-point environment when using strtod
to implement std::from_chars.

The destructors for the RAII objects run slightly later than the
previous statements that restored the locale/fenv, but the differences
are just some trivial assignments and an isinf call.

Reviewed-by: Patrick Palka <ppalka@redhat.com>
libstdc++-v3/ChangeLog:

* src/c++17/floating_from_chars.cc [USE_STRTOD_FOR_FROM_CHARS]
(auto_locale, auto_ferounding): New class types.
(from_chars_impl): Use auto_locale and auto_ferounding.
libstdc++-v3/src/c++17/floating_from_chars.cc