5.3.0
版本发布时间: 2018-12-29 04:36:04
fmtlib/fmt最新发布版本:11.0.2(2024-07-20 22:32:04)
-
Introduced experimental chrono formatting support:
#include <fmt/chrono.h> int main() { using namespace std::literals::chrono_literals; fmt::print("Default format: {} {}\n", 42s, 100ms); fmt::print("strftime-like format: {:%H:%M:%S}\n", 3h + 15min + 30s); }
prints:
Default format: 42s 100ms strftime-like format: 03:15:30
-
Added experimental support for emphasis (bold, italic, underline, strikethrough), colored output to a file stream, and improved colored formatting API (#961, #967, #973):
#include <fmt/color.h> int main() { print(fg(fmt::color::crimson) | fmt::emphasis::bold, "Hello, {}!\n", "world"); print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | fmt::emphasis::underline, "Hello, {}!\n", "мир"); print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, "Hello, {}!\n", "世界"); }
prints the following on modern terminals with RGB color support:
Thanks @Rakete1111 (Nicolas).
-
Added support for 4-bit terminal colors (#968, #974)
#include <fmt/color.h> int main() { print(fg(fmt::terminal_color::red), "stop\n"); }
Note that these colors vary by terminal:Thanks @Rakete1111 (Nicolas).
-
Parameterized formatting functions on the type of the format string (#880, #881, #883, #885, #897, #920). Any object of type
S
that has an overloadedto_string_view(const S&)
returningfmt::string_view
can be used as a format string:namespace my_ns { inline string_view to_string_view(const my_string& s) { return {s.data(), s.length()}; } } std::string message = fmt::format(my_string("The answer is {}."), 42);
Thanks @DanielaE (Daniela Engert).
-
Made
std::string_view
work as a format string (#898):auto message = fmt::format(std::string_view("The answer is {}."), 42);
Thanks @DanielaE (Daniela Engert).
-
Added wide string support to compile-time format string checks (#924):
print(fmt(L"{:f}"), 42); // compile-time error: invalid type specifier
Thanks @XZiar.
-
Made colored print functions work with wide strings (#867):
#include <fmt/color.h> int main() { print(fg(fmt::color::red), L"{}\n", 42); }
Thanks @DanielaE (Daniela Engert).
-
Introduced experimental Unicode support (#628, #891):
using namespace fmt::literals; auto s = fmt::format("{:*^5}"_u, "🤡"_u); // s == "**🤡**"_u
-
Improved locale support:
#include <fmt/locale.h> struct numpunct : std::numpunct<char> { protected: char do_thousands_sep() const override { return '~'; } }; std::locale loc; auto s = fmt::format(std::locale(loc, new numpunct()), "{:n}", 1234567); // s == "1~234~567"
-
Constrained formatting functions on proper iterator types (#921). Thanks @DanielaE (Daniela Engert).
-
Added
make_printf_args
andmake_wprintf_args
functions (#934). Thanks @tnovotny. -
Deprecated
fmt::visit
,parse_context
, andwparse_context
. Usefmt::visit_format_arg
,format_parse_context
, andwformat_parse_context
instead. -
Removed undocumented
basic_fixed_buffer
which has been superseded by the iterator-based API (#873, #902). Thanks @superfunc (hollywood programmer). -
Disallowed repeated leading zeros in an argument ID:
fmt::print("{000}", 42); // error
-
Reintroduced support for gcc 4.4.
-
Fixed compilation on platforms with exotic
double
(#878). -
Improved documentation (#164, #877, #901, #906, #979). Thanks @kookjr (Mathew Cucuzella), @DarkDimius (Dmitry Petrashko), @HecticSerenity.
-
Added pkgconfig support which makes it easier to consume the library from meson and other build systems (#916). Thanks @colemickens (Cole Mickens).
-
Various build improvements (#909, #926, #937, #953, #959). Thanks @tchaikov (Kefu Chai), @luncliff (Park DongHa), @AndreasSchoenle (Andreas Schönle), @hotwatermorning, @Zefz (JohanJansen).
-
Improved
string_view
construction performance (#914). Thanks @gabime (Gabi Melman). -
Fixed non-matching char types (#895). Thanks @DanielaE (Daniela Engert).
-
Fixed
format_to_n
withstd::back_insert_iterator
(#913). Thanks @DanielaE (Daniela Engert). -
Fixed locale-dependent formatting (#905).
-
Fixed various compiler warnings and errors (#882, #886, #933, #941, #931, #943, #954, #956, #962, #965, #977, #983, #989). Thanks @Luthaf (Guillaume Fraux), @stevenhoving (Steven Hoving), @christinaa (Kristina Brooks), @lgritz (Larry Gritz), @DanielaE (Daniela Engert), @0x8000-0000 (Sign Bit), @liuping1997.
1、 fmt-5.3.0.zip 1.02MB