Maybe this is a dumb question, but is there any way to convert a boolean value to a string such that 1 turns to \"true\" and 0 turns to \"false\"? I could just use an if st
C++20 std::format("{}"
https://en.cppreference.com/w/cpp/utility/format/formatter#Standard_format_specification claims that the default output format will be the string by default:
auto s6 = std::format("{:6}", true); // value of s6 is "true "
and:
The available bool presentation types are:
- none, s: Copies textual representation (true or false, or the locale-specific form) to the output.
- b, B, c, d, o, x, X: Uses integer presentation types with the value static_cast(value).
Related: std::string formatting like sprintf