
On October 7, 2025 11:15:36 AM Gennaro Prota via Boost <boost@lists.boost.org> wrote:
Hi everyone,
I'd like to gather your input on the desired behavior of to_static_string() and to_static_wstring() when formatting floating point values.
Currently, both functions mimic std::to_string() / std::to_wstring() as long as the result fits within the static string's capacity. If not, they fall back to scientific notation.
However, C++26 introduces a breaking change: std::to_string() and std::to_wstring() will behave as if implemented via std::format() rather than s[w]printf(). For example, std::to_string( 0.1 ) will yield "0.1" instead of "0.100000".
Given this shift, what behavior would you prefer for to_static_[w]string()?
a) Match std::to_[w]string() and adopt the new behavior when compiling under C++26.
b) Preserve the legacy behavior with fixed precision (6 digits) across all standard versions.
c) Always behave as if using std::format(), even in pre-C++26 builds (breaking change).
d) Other.
Please let me know what you think.
Any to_(whatever_)string functions should produce the same result, regardless of the standard version. Otherwise, you'd be laying landmines to users. Better break users once than keep them breaking themselves all the time. So option c.