KyleVaughn / UM2

An unstructured mesh library for automated method of characteristic mesh generation
https://univeristy-of-michigan-unstructured-mesh-code.readthedocs.io/en/main/index.html#
MIT License
7 stars 2 forks source link

Implement better conversion to strings and better formatting using fmt/std::format #155

Open KyleVaughn opened 5 months ago

KyleVaughn commented 5 months ago

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.