
I favour option c. I implemented my own static_string class which is also usable on ancient compilers. This is my comment for the to_fc_string function: // Conversion double/float => fc_string is not completely standard. // Before C++20 this is defined as using %f which requires more than // 300 bytes to store // C++20 makes this more reasonable so do not rely to much on the // exact result of this conversion for very small or large values // Please note that the standard formats a float as a double. // We currently save space and only store significant digits of both // types. If I remember correctly this will not always give the exact same result as C++20, but is it good enough. And the actual implementation is basically sprintf(res,"%0.17g",value) for double. /Peter On Tue, Oct 7, 2025 at 10:16 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.
Thanks.
-- Gennaro Prota <https://prota.dev>
_______________________________________________ Boost mailing list -- boost@lists.boost.org To unsubscribe send an email to boost-leave@lists.boost.org https://lists.boost.org/mailman3/lists/boost.lists.boost.org/ Archived at: https://lists.boost.org/archives/list/boost@lists.boost.org/message/LMTGWPUG...