feat(Format): add support for %g and %G format specifiers

This commit is contained in:
nyashbox 2024-12-02 02:09:35 +02:00
parent 02c86d4cdd
commit 42da9b0f1e
No known key found for this signature in database
GPG Key ID: B40E74A291D1DFA4
2 changed files with 6 additions and 0 deletions

View File

@ -62,6 +62,8 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
/// * e signed floating-point value in the form [-]d.dddde[<sign>]dd[d]
/// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d]
/// * f signed floating-point value in the form [-]dddd.dddd
/// * g use the shortest representation: %e or %f
/// * G use the shortest representation: %E or %F
/// * s std::string
/// * v std::string_view
/// * z std::size_t

View File

@ -128,6 +128,8 @@ namespace
case 'e': str << std::scientific; break;
case 'E': str << std::scientific << std::uppercase; break;
case 'f': str << std::fixed; break;
case 'g': str << std::defaultfloat; break;
case 'G': str << std::defaultfloat << std::uppercase; break;
}
}
@ -212,6 +214,8 @@ namespace
case 'e':
case 'E':
case 'f':
case 'g':
case 'G':
switch (mod)
{
case 'l': str << AnyCast<long double>(*itVal++); break;