8.1.0
版本发布时间: 2022-01-03 01:17:55
fmtlib/fmt最新发布版本:11.0.2(2024-07-20 22:32:04)
Optimized chrono formatting (#2500, #2537, #2541, #2544, #2550, #2551, #2576, #2577, #2586, #2591, #2594, #2602, #2617, #2628, #2633, #2670, #2671).
Processing of some specifiers such as %z
and %Y
is now up to 10-20 times faster, for example on GCC 11 with libstdc++:
----------------------------------------------------------------------------
Benchmark Before After
----------------------------------------------------------------------------
FMTFormatter_z 261 ns 26.3 ns
FMTFormatterCompile_z 246 ns 11.6 ns
FMTFormatter_Y 263 ns 26.1 ns
FMTFormatterCompile_Y 244 ns 10.5 ns
----------------------------------------------------------------------------
Thanks @phprus (Vladislav Shchapov) and @toughengineer (Pavel Novikov).
Implemented subsecond formatting for chrono durations (#2623). For example (godbolt):
#include <fmt/chrono.h>
int main() {
fmt::print("{:%S}", std::chrono::milliseconds(1234));
}
prints "01.234".
Thanks @matrackif.
Fixed handling of precision 0 when formatting chrono durations (#2587, #2588). Thanks @lukester1975.
Fixed an overflow on invalid inputs in the tm
formatter (#2564). Thanks @phprus (Vladislav Shchapov).
Added fmt::group_digits
that formats integers with a non-localized digit separator (comma) for groups of three digits. For example (godbolt):
#include <fmt/format.h>
int main() {
fmt::print("{} dollars", fmt::group_digits(1000000));
}
prints "1,000,000 dollars".
Added support for faint, conceal, reverse and blink text styles (#2394):
https://user-images.githubusercontent.com/576385/147710227-c68f5317-f8fa-42c3-9123-7c4ba3c398cb.mp4
Thanks @benit8 (Benoît Lormeau) and @data-man (Dmitry Atamanov).
Added experimental support for compile-time floating point formatting (#2426, #2470). It is currently limited to the header-only mode. Thanks @alexezeder (Alexey Ochapov).
Added UDL-based named argument support to compile-time format string checks (#2640, #2649). For example (godbolt):
#include <fmt/format.h>
int main() {
using namespace fmt::literals;
fmt::print("{answer:s}", "answer"_a=42);
}
gives a compile-time error on compilers with C++20 consteval
and non-type template parameter support (gcc 10+) because s
is not a valid format specifier for an integer.
Thanks @alexezeder (Alexey Ochapov).
Implemented escaping of string range elements. For example (godbolt):
#include <fmt/ranges.h>
#include <vector>
int main() {
fmt::print("{}", std::vector<std::string>{"\naan"});
}
is now printed as:
["\naan"]
instead of:
["
aan"]
Switched to JSON-like representation of maps and sets for consistency with Python's str.format
. For example (godbolt):
#include <fmt/ranges.h>
#include <map>
int main() {
fmt::print("{}", std::map<std::string, int>{{"answer", 42}});
}
is now printed as:
{"answer": 42}
Extended fmt::join
to support C++20-only ranges (#2549). Thanks @BRevzin (Barry Revzin).
Optimized handling of non-const-iterable ranges and implemented initial support for non-const-formattable types.
Disabled implicit conversions of scoped enums to integers that was accidentally introduced in earlier versions (#1841).
Deprecated implicit conversion of [const] signed char*
and [const] unsigned char*
to C strings.
Deprecated _format
, a legacy UDL-based format API (#2646). Thanks @alexezeder (Alexey Ochapov).
Marked format
, formatted_size
and to_string
as [[nodiscard]]
(#2612). @0x8000-0000 (Florin Iucha).
Added missing diagnostic when trying to format function and member pointers as well as objects convertible to pointers which is explicitly disallowed (#2598, #2609, #2610). Thanks @AlexGuteniev (Alex Guteniev).
Optimized writing to a contiguous buffer with format_to_n
(#2489). Thanks @Roman-Koshelev.
Optimized writing to non-char
buffers (#2477). Thanks @Roman-Koshelev.
Decimal point is now localized when using the L
specifier.
Improved floating point formatter implementation (#2498, #2499). Thanks @Roman-Koshelev.
Fixed handling of very large precision in fixed format (#2616).
Made a table of cached powers used in FP formatting static (#2509). Thanks @jk-jeon (Junekey Jeon).
Resolved a lookup ambiguity with C++20 format-related functions due to ADL (#2639, #2641). Thanks @mkurdej (Marek Kurdej).
Removed unnecessary inline namespace qualification (#2642, #2643). Thanks @mkurdej (Marek Kurdej).
Implemented argument forwarding in format_to_n
(#2462, #2463). Thanks @owent (WenTao Ou).
Fixed handling of implicit conversions in fmt::to_string
and format string compilation (#2565).
Changed the default access mode of files created by fmt::output_file
to -rw-r--r--
for consistency with fopen
(#2530).
Make fmt::ostream::flush
public (#2435).
Improved C++14/17 attribute detection (#2615). Thanks @AlexGuteniev (Alex Guteniev).
Improved consteval
detection for MSVC (#2559). Thanks @DanielaE (Daniela Engert).
Improved documentation (#2406, #2446, #2493, #2513, #2515, #2522, #2562, #2575, #2606, #2620, #2676). Thanks @sobolevn (Nikita Sobolev), @UnePierre (Max FERGER), @zhsj, @phprus (Vladislav Shchapov), @ericcurtin (Eric Curtin), @Lounarok.
Improved fuzzers and added a fuzzer for chrono timepoint formatting (#2461, #2469). @pauldreik (Paul Dreik),
Added the FMT_SYSTEM_HEADERS
CMake option setting which marks {fmt}'s headers as system. It can be used to suppress warnings (#2644, #2651). Thanks @alexezeder (Alexey Ochapov).
Added the Bazel build system support (#2505, #2516). Thanks @Vertexwahn.
Improved build configuration and tests (#2437, #2558, #2648, #2650, #2663, #2677). Thanks @DanielaE (Daniela Engert), @alexezeder (Alexey Ochapov), @phprus (Vladislav Shchapov).
Fixed various warnings and compilation issues (#2353, #2356, #2399, #2408, #2414, #2427, #2432, #2442, #2434, #2439, #2447, #2450, #2455, #2465, #2472, #2474, #2476, #2478, #2479, #2481, #2482, #2483, #2490, #2491, #2510, #2518, #2528, #2529, #2539, #2540, #2545, #2555, #2557, #2570, #2573, #2582, #2605, #2611, #2647, #2627, #2630, #2635, #2638, #2653, #2654, #2661, #2664, #2684). Thanks @DanielaE (Daniela Engert), @mwinterb, @cdacamar (Cameron DaCamara), @TrebledJ (Johnathan), @bodomartin (brm), @cquammen (Cory Quammen), @white238 (Chris White), @mmarkeloff (Max), @palacaze (Pierre-Antoine Lacaze), @jcelerier (Jean-Michaël Celerier), @mborn-adi (Mathias Born), @BrukerJWD (Jonathan W), @spyridon97 (Spiros Tsalikis), @phprus (Vladislav Shchapov), @oliverlee (Oliver Lee), @joshessman-llnl (Josh Essman), @akohlmey (Axel Kohlmeyer), @timkalu, @olupton (Olli Lupton), @Acretock, @alexezeder (Alexey Ochapov), @andrewcorrigan (Andrew Corrigan), @lucpelletier, @HazardyKnusperkeks (Björn Schäpers).
1、 fmt-8.1.0.zip 1.19MB