You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, writing non-string arguments to C-strings or String uses snprintf to write to a buffer. This is not the most performant nor the most elegant solution to this problem. C++-20 adopted std::format (in particular std::format_to_n) for this purpose. We would like to use std::format, but the minimum compiler versions supported by UM2 do not implement std::format.
Since https://github.com/fmtlib/fmt is the reference implementation of std::format and is very widely used, it seems like a reasonable solution is to conditionally include this library. For compilers which support std::format, inclusion of the library can be omitted. In the future if the minimum UM2 standard is bumped to C++23 and we want to drop fmtlib entirely, the only required changes to the code would be the conditional aliasing of fmt vs std in a header.
Replace usage of snprintf in String, the logger, and I/O with std::format_to_n
Find an alternative to log.hpp's toBuffer. This might just effectively be std::format_to_n.
Write a toBuffer equivalent for Vec.
The text was updated successfully, but these errors were encountered:
Currently, writing non-string arguments to C-strings or String uses
snprintf
to write to a buffer. This is not the most performant nor the most elegant solution to this problem. C++-20 adoptedstd::format
(in particularstd::format_to_n
) for this purpose. We would like to usestd::format
, but the minimum compiler versions supported by UM2 do not implementstd::format
.Since https://github.com/fmtlib/fmt is the reference implementation of
std::format
and is very widely used, it seems like a reasonable solution is to conditionally include this library. For compilers which supportstd::format
, inclusion of the library can be omitted. In the future if the minimum UM2 standard is bumped to C++23 and we want to drop fmtlib entirely, the only required changes to the code would be the conditional aliasing of fmt vs std in a header.snprintf
in String, the logger, and I/O withstd::format_to_n
toBuffer
. This might just effectively bestd::format_to_n
.toBuffer
equivalent for Vec.The text was updated successfully, but these errors were encountered: