from_chars
pattern specification breaks round-trippingSection: 28.2.3 [charconv.from.chars] Status: C++20 Submitter: Greg Falcon Opened: 2018-03-12 Last modified: 2021-02-25
Priority: 0
View other active issues in [charconv.from.chars].
View all other issues in [charconv.from.chars].
View all issues with C++20 status.
Discussion:
from_chars
specifies that the '+'
character is never matched, but to_chars
specifies its output format in terms of printf()
, which puts a '+'
sign before
positive exponents.
strtod()
matches '+'
signs, it is also desirable to accept '+'
in
exponents, so that code currently using strtod()
can be migrated to from_chars()
without a breaking semantic change.
[ 2018-03-27 Moved to Tentatively Ready after 9 positive votes on c++std-lib. ]
[2018-06 Rapperswil: Adopted]
Proposed resolution:
This wording is relative to N4727.
Edit 28.2.3 [charconv.from.chars] as indicated:
from_chars_result from_chars(const char* first, const char* last, float& value, chars_format fmt = chars_format::general); from_chars_result from_chars(const char* first, const char* last, double& value, chars_format fmt = chars_format::general); from_chars_result from_chars(const char* first, const char* last, long double& value, chars_format fmt = chars_format::general);-6- Requires:
-7- Effects: The pattern is the expected form of the subject sequence in thefmt
has the value of one of the enumerators ofchars_format
."C"
locale, as described forstrtod
, except that
(7.1) — the
onlysign'+'
thatmay only appearisin the exponent part;'-'
(7.2) […]
(7.3) […]
(7.4) […]