6.1.0
版本发布时间: 2019-12-02 22:15:47
fmtlib/fmt最新发布版本:11.0.2(2024-07-20 22:32:04)
-
{fmt} now formats IEEE 754
float
anddouble
using the shortest decimal representation with correct rounding by default:#include <cmath> #include <fmt/core.h> int main() { fmt::print("{}", M_PI); }
prints
3.141592653589793
. -
Made the fast binary to decimal floating-point formatter the default, simplified it and improved performance. {fmt} is now 15 times faster than libc++'s
std::ostringstream
, 11 times faster thanprintf
and 10% faster than double-conversion on dtoa-benchmark:Function Time (ns) Speedup ostringstream 1,346.30 1.00x ostrstream 1,195.74 1.13x sprintf 995.08 1.35x doubleconv 99.10 13.59x fmt 88.34 15.24x -
{fmt} no longer converts
float
arguments todouble
. In particular this improves the default (shortest) representation of floats and makesfmt::format
consistent withstd::format
specs (#1336, #1353, #1360, #1361):fmt::print("{}", 0.1f);
prints
0.1
instead of0.10000000149011612
. Thanks @orivej (Orivej Desh). -
Made floating-point formatting output consistent with
printf
/iostreams (#1376, #1417). -
Added support for 128-bit integers (#1287):
fmt::print("{}", std::numeric_limits<__int128_t>::max());
prints
170141183460469231731687303715884105727
. Thanks @denizevrenci (Deniz Evrenci). -
The overload of
print
that takestext_style
is now atomic, i.e. the output from different threads doesn't interleave (#1351). Thanks @tankiJong (Tanki Zhang). -
Made compile time in the header-only mode ~20% faster by reducing the number of template instantiations.
wchar_t
overload ofvprint
was moved fromfmt/core.h
tofmt/format.h
. -
Added an overload of
fmt::join
that works with tuples (#1322, #1330):#include <tuple> #include <fmt/ranges.h> int main() { std::tuple<char, int, float> t{'a', 1, 2.0f}; fmt::print("{}", t); }
prints
('a', 1, 2.0)
. Thanks @jeremyong (Jeremy Ong). -
Changed formatting of octal zero with prefix from "00" to "0":
fmt::print("{:#o}", 0);
prints
0
. -
The locale is now passed to ostream insertion (
<<
) operators (#1406):#include <fmt/locale.h> #include <fmt/ostream.h> struct S { double value; }; std::ostream& operator<<(std::ostream& os, S s) { return os << s.value; } int main() { auto s = fmt::format(std::locale("fr_FR.UTF-8"), "{}", S{0.42}); // s == "0,42" }
Thanks @dlaugt (Daniel Laügt).
-
Locale-specific number formatting now uses grouping (#1393 #1394). Thanks @skrdaniel.
-
Fixed handling of types with deleted implicit rvalue conversion to
const char**
(#1421):struct mystring { operator const char*() const&; operator const char*() &; operator const char*() const&& = delete; operator const char*() && = delete; }; mystring str; fmt::print("{}", str); // now compiles
-
Enums are now mapped to correct underlying types instead of
int
(#1286). Thanks @agmt (Egor Seredin). -
Enum classes are no longer implicitly converted to
int
(#1424). -
Added
basic_format_parse_context
for consistency with C++20std::format
and deprecatedbasic_parse_context
. -
Fixed handling of UTF-8 in precision (#1389, #1390). Thanks @tajtiattila (Attila Tajti).
-
{fmt} can now be installed on Linux, macOS and Windows with Conda using its conda-forge package (#1410):
conda install -c conda-forge fmt
Thanks @tdegeus (Tom de Geus).
-
Added a CUDA test (#1285, #1317). Thanks @luncliff (Park DongHa) and @risa2000.
-
Improved documentation (#1276, #1291, #1296, #1315, #1332, #1337, #1395 #1418). Thanks @waywardmonkeys (Bruce Mitchener), @pauldreik (Paul Dreik), @jackoalan (Jack Andersen).
-
Various code improvements (#1358, #1407). Thanks @orivej (Orivej Desh), @dpacbach (David P. Sicilia),
-
Fixed compile-time format string checks for user-defined types (#1292).
-
Worked around a false positive in
unsigned-integer-overflow
sanitizer (#1377). -
Fixed various warnings and compilation issues (#1273, #1278, #1280, #1281, #1288, #1290, #1301, #1305, #1306, #1309, #1312, #1313, #1316, #1319, #1320, #1326, #1328, #1344, #1345, #1347, #1349, #1354, #1362, #1366, #1364, #1370, #1371, #1385, #1388, #1397, #1414, #1416, #1422 #1427, #1431, #1433). Thanks @hhb, @gsjaardema (Greg Sjaardema), @gabime (Gabi Melman), @neheb (Rosen Penev), @vedranmiletic (Vedran Miletić), @dkavolis (Daumantas Kavolis), @mwinterb, @orivej (Orivej Desh), @denizevrenci (Deniz Evrenci) @leonklingele, @chronoxor (Ivan Shynkarenka), @kent-tri, @0x8000-0000 (Florin Iucha), @marti4d (Chris Martin).
1、 fmt-6.1.0.zip 1.09MB