6.2.0
-
Improved error reporting when trying to format an object of a non-formattable type:
fmt::format("{}", S());
now gives:
include/fmt/core.h:1015:5: error: static_assert failed due to requirement 'formattable' "Cannot format argument. To make type T formattable provide a formatter<T> specialization: https://fmt.dev/latest/api.html#formatting-user-defined-types" static_assert( ^ ... note: in instantiation of function template specialization 'fmt::v6::format<char [3], S, char>' requested here fmt::format("{}", S()); ^
if
S
is not formattable. -
Reduced library size by ~10%.
-
Always print decimal point if
#
is specified (#1476, #1498):fmt::print("{:#.0f}", 42.0);
now prints
42.
-
Implemented the
'L'
specifier for locale-specific numeric formatting to improve compatibility withstd::format
. The'n'
specifier is now deprecated and will be removed in the next major release. -
Moved OS-specific APIs such as
windows_error
fromfmt/format.h
tofmt/os.h
. You can defineFMT_DEPRECATED_INCLUDE_OS
to automatically includefmt/os.h
fromfmt/format.h
for compatibility but this will be disabled in the next major release. -
Added precision overflow detection in floating-point formatting.
-
Implemented detection of invalid use of
fmt::arg
. -
Used
type_identity
to block unnecessary template argument deduction. Thanks Tim Song. -
Improved UTF-8 handling (#1109):
fmt::print("┌{0:─^{2}}┐\n" "│{1: ^{2}}│\n" "└{0:─^{2}}┘\n", "", "Привет, мир!", 20);
now prints:
┌────────────────────┐ │ Привет, мир! │ └────────────────────┘
on systems that support Unicode.
-
Added experimental dynamic argument storage (#1170, #1584):
fmt::dynamic_format_arg_store<fmt::format_context> store; store.push_back("answer"); store.push_back(42); fmt::vprint("The {} is {}.\n", store);
prints:
The answer is 42.
-
Made
fmt::join
acceptinitializer_list
(#1591). Thanks @Rapotkinnik (Nikolay Rapotkin). -
Fixed handling of empty tuples (#1588).
-
Fixed handling of output iterators in
format_to_n
(#1506). -
Fixed formatting of
std::chrono::duration
types to wide output (#1533). Thanks @zeffy (pilao). -
Added const
begin
andend
overload to buffers (#1553). Thanks @dominicpoeschko. -
Added the ability to disable floating-point formatting via
FMT_USE_FLOAT
,FMT_USE_DOUBLE
andFMT_USE_LONG_DOUBLE
macros for extremely memory-constrained embedded system (#1590). Thanks @albaguirre (Alberto Aguirre). -
Made
FMT_STRING
work withconstexpr
string_view
(#1589). Thanks @scramsby (Scott Ramsby). -
Implemented a minor optimization in the format string parser (#1560). Thanks @IkarusDeveloper.
-
Improved attribute detection (#1469, #1475, #1576). Thanks @federico-busato (Federico), @chronoxor (Ivan Shynkarenka), @refnum.
-
Improved documentation (#1481, #1523). Thanks @JackBoosY (Jack·Boos·Yu), @imba-tjd (谭九鼎).
-
Fixed symbol visibility on Linux when compiling with
-fvisibility=hidden
(#1535). Thanks @milianw (Milian Wolff). -
Implemented various build configuration fixes and improvements (#1264, #1460, #1534, #1536, #1545, #1546, #1566, #1582, #1597, #1598). Thanks @ambitslix (Attila M. Szilagyi), @jwillikers (Jordan Williams), @stac47 (Laurent Stacul).
-
Fixed various warnings and compilation issues (#1433, #1461, #1470, #1480, #1485, #1492, #1493, #1504, #1505, #1512, #1515, #1516, #1518, #1519, #1520, #1521, #1522, #1524, #1530, #1531, #1532, #1539, #1547, #1548, #1554, #1567, #1568, #1569, #1571, #1573, #1575, #1581, #1583, #1586, #1587, #1594, #1596, #1604, #1606, #1607, #1609). Thanks @marti4d (Chris Martin), @iPherian, @parkertomatoes, @gsjaardema (Greg Sjaardema), @chronoxor (Ivan Shynkarenka), @DanielaE (Daniela Engert), @torsten48, @tohammer (Tobias Hammer), @lefticus (Jason Turner), @ryusakki (Haise), @adnsv (Alex Denisov), @fghzxm, @refnum, @pramodk (Pramod Kumbhar), @Spirrwell, @scramsby (Scott Ramsby).