Skip to content

Commit b1fdcd5

Browse files
authored
Merge 2023-06 LWG Motion 4
P2587R3 to_string or not to_string
2 parents dcbfa46 + de67fc3 commit b1fdcd5

File tree

3 files changed

+21
-25
lines changed

3 files changed

+21
-25
lines changed

source/compatibility.tex

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@
3131
bool b = ne({2,3}, {1,2,3}); // unspecified result; previously \tcode{false}
3232
\end{example}
3333

34+
\rSec2[diff.cpp23.strings]{\ref{strings}: strings library}
35+
36+
\diffref{string.conversions}
37+
\change
38+
Output of floating-point overloads of \tcode{to_string} and \tcode{to_wstring}.
39+
\rationale
40+
Prevent loss of information and improve consistency with other formatting
41+
facilities.
42+
\effect
43+
\tcode{to_string} and \tcode{to_wstring} function calls that take
44+
floating-point arguments may produce a different output.
45+
For example:
46+
\begin{codeblock}
47+
auto s = std::to_string(1e-7); // \tcode{"1e-07"}
48+
// previously \tcode{"0.000000"} with \tcode{'.'} possibly
49+
// changed according to the global C locale
50+
\end{codeblock}
51+
3452
\rSec1[diff.cpp20]{\Cpp{} and ISO \CppXX{}}
3553

3654
\rSec2[diff.cpp20.general]{General}

source/strings.tex

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5196,18 +5196,7 @@
51965196
\begin{itemdescr}
51975197
\pnum
51985198
\returns
5199-
Each function returns a \tcode{string} object holding the character
5200-
representation of the value of its argument that would be generated by calling
5201-
\tcode{sprintf(buf, fmt, val)} with a format specifier of
5202-
\tcode{"\%d"},
5203-
\tcode{"\%u"},
5204-
\tcode{"\%ld"},
5205-
\tcode{"\%lu"},
5206-
\tcode{"\%lld"}, \tcode{"\%llu"},
5207-
\tcode{"\%f"},
5208-
\tcode{"\%f"},
5209-
or \tcode{"\%Lf"}, respectively, where \tcode{buf} designates an internal
5210-
character buffer of sufficient size.
5199+
\tcode{format("\{\}", val)}.
52115200
\end{itemdescr}
52125201

52135202
\indexlibraryglobal{stoi}%
@@ -5294,19 +5283,7 @@
52945283
\begin{itemdescr}
52955284
\pnum
52965285
\returns
5297-
Each function returns a \tcode{wstring} object holding the character
5298-
representation of the value of its argument that would be generated by calling
5299-
\tcode{swprintf(buf, buffsz, fmt, val)} with a format specifier of
5300-
\tcode{L"\%d"},
5301-
\tcode{L"\%u"},
5302-
\tcode{L"\%ld"},
5303-
\tcode{L"\%lu"},
5304-
\tcode{L"\%lld"},
5305-
\tcode{L"\%llu"},
5306-
\tcode{L"\%f"},
5307-
\tcode{L"\%f"},
5308-
or \tcode{L"\%Lf"}, respectively, where \tcode{buf} designates an
5309-
internal character buffer of sufficient size \tcode{buffsz}.
5286+
\tcode{format(L"\{\}", val)}.
53105287
\end{itemdescr}
53115288

53125289
\rSec2[basic.string.hash]{Hash support}

source/support.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,7 @@
736736
#define @\defnlibxname{cpp_lib_to_address}@ 201711L // also in \libheader{memory}
737737
#define @\defnlibxname{cpp_lib_to_array}@ 201907L // also in \libheader{array}
738738
#define @\defnlibxname{cpp_lib_to_chars}@ 202306L // also in \libheader{charconv}
739+
#define @\defnlibxname{cpp_lib_to_string}@ 202306L // also in \libheader{string}
739740
#define @\defnlibxname{cpp_lib_to_underlying}@ 202102L // also in \libheader{utility}
740741
#define @\defnlibxname{cpp_lib_transformation_trait_aliases}@ 201304L // also in \libheader{type_traits}
741742
#define @\defnlibxname{cpp_lib_transparent_operators}@ 201510L // also in \libheader{memory}, \libheader{functional}

0 commit comments

Comments
 (0)