
Gennaro Prota 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.
c)