fmtlib/fmt
### [`v9.1.0`](https://togithub.com/fmtlib/fmt/blob/HEAD/ChangeLog.rst#910---2022-08-27)
[Compare Source](https://togithub.com/fmtlib/fmt/compare/9.0.0...9.1.0)
- `fmt::formatted_size` now works at compile time
(`#3026 `\_). For example
(`godbolt `\__):
.. code:: c++
\#include \
int main() {
using namespace fmt::literals;
constexpr size_t n = fmt::formatted_size("{}"\_cf, 42);
fmt::print("{}\n", n); // prints 2
}
Thanks `@marksantaniello (Mark Santaniello) `\_.
- Fixed handling of invalid UTF-8
(`#3038 `*,
`#3044 `*,
`#3056 `*).
Thanks `@phprus (Vladislav Shchapov) `* and
`@skeeto (Christopher Wellons) `\_.
- Improved Unicode support in `ostream` overloads of `print`
(`#2994 `*,
`#3001 `*,
`#3025 `*).
Thanks `@dimztimz (Dimitrij Mijoski) `*.
- Fixed handling of the sign specifier in localized formatting on systems with
32-bit `wchar_t` (`#3041 `\_).
- Added support for wide streams to `fmt::streamed`
(`#2994 `*).
Thanks `@phprus (Vladislav Shchapov) `*.
- Added the `n` specifier that disables the output of delimiters when
formatting ranges (`#2981 `*,
`#2983 `*).
For example (`godbolt `\__):
.. code:: c++
\#include \
\#include
int main() {
auto v = std::vector{1, 2, 3};
fmt::print("{:n}\n", v); // prints 1, 2, 3
}
Thanks `@BRevzin (Barry Revzin) `\_.
- Worked around problematic `std::string_view` constructors introduced in
C++23 (`#3030 `*,
`#3050 `*).
Thanks `@strega-nil-ms (nicole mazzuca) `\_.
- Improve handling (exclusion) of recursive ranges
(`#2968 `*,
`#2974 `*).
Thanks `@Dani-Hub (Daniel Krügler) `\_.
- Improved error reporting in format string compilation
(`#3055 `\_).
- Improved the implementation of
`Dragonbox `*, the algorithm used for
the default floating-point formatting
(`#2984 `*).
Thanks `@jk-jeon (Junekey Jeon) `\_.
- Fixed issues with floating-point formatting on exotic platforms.
- Improved the implementation of chrono formatting
(`#3010 `*).
Thanks `@phprus (Vladislav Shchapov) `*.
- Improved documentation
(`#2966 `*,
`#3009 `*,
`#3020 `*,
`#3037 `*).
Thanks `@mwinterb `*,
`@jcelerier (Jean-Michaël Celerier) `*
and `@remiburtin (Rémi Burtin) `\_.
- Improved build configuration
(`#2991 `*,
`#2995 `*,
`#3004 `*,
`#3007 `*,
`#3040 `*).
Thanks `@dimztimz (Dimitrij Mijoski) `* and
`@hwhsu1231 (Haowei Hsu) `\_.
- Fixed various warnings and compilation issues
(`#2969 `*,
`#2971 `*,
`#2975 `*,
`#2982 `*,
`#2985 `*,
`#2988 `*,
`#3000 `*,
`#3006 `*,
`#3014 `*,
`#3015 `*,
`#3021 `*,
`#3023 `*,
`#3024 `*,
`#3029 `*,
`#3043 `*,
`#3052 `*,
`#3053 `*,
`#3054 `*).
Thanks `@h-friederich (Hannes Friederich) `*,
`@dimztimz (Dimitrij Mijoski) `*,
`@olupton (Olli Lupton) `*,
`@bernhardmgruber (Bernhard Manfred Gruber) `*,
`@phprus (Vladislav Shchapov) `\_.
### [`v9.0.0`](https://togithub.com/fmtlib/fmt/blob/HEAD/ChangeLog.rst#900---2022-07-04)
[Compare Source](https://togithub.com/fmtlib/fmt/compare/8.1.1...9.0.0)
- Switched to the internal floating point formatter for all decimal presentation
formats. In particular this results in consistent rounding on all platforms
and removing the `s[n]printf` fallback for decimal FP formatting.
- Compile-time floating point formatting no longer requires the header-only
mode. For example (`godbolt `\__):
.. code:: c++
\#include
\#include \
consteval auto compile_time_dtoa(double value) -> std::array\ {
auto result = std::array\();
fmt::format_to(result.data(), FMT_COMPILE("{}"), value);
return result;
}
constexpr auto answer = compile_time_dtoa(0.42);
works with the default settings.
- Improved the implementation of
`Dragonbox `*, the algorithm used for
the default floating-point formatting
(`#2713 `*,
`#2750 `*).
Thanks `@jk-jeon (Junekey Jeon) `*.
- Made `fmt::to_string` work with `__float128`. This uses the internal
FP formatter and works even on system without `__float128` support in
`[s]printf`.
- Disabled automatic `std::ostream` insertion operator (`operator<<`)
discovery when `fmt/ostream.h` is included to prevent ODR violations.
You can get the old behavior by defining `FMT_DEPRECATED_OSTREAM` but this
will be removed in the next major release. Use `fmt::streamed` or
`fmt::ostream_formatter` to enable formatting via `std::ostream` instead.
- Added `fmt::ostream_formatter` that can be used to write `formatter`
specializations that perform formatting via `std::ostream`.
For example (`godbolt `\__):
.. code:: c++
\#include \
struct date {
int year, month, day;
friend std::ostream& operator<<(std::ostream& os, const date& d) {
return os << d.year << '-' << d.month << '-' << d.day;
}
};
template <> struct fmt::formatter : ostream_formatter {};
std::string s = fmt::format("The date is {}", date{2012, 12, 9});
// s == "The date is 2012-12-9"
- Added the `fmt::streamed` function that takes an object and formats it
via `std::ostream`.
For example (`godbolt `\__):
.. code:: c++
\#include
\#include \
int main() {
fmt::print("Current thread id: {}\n",
fmt::streamed(std::this_thread::get_id()));
}
Note that `fmt/std.h` provides a `formatter` specialization for
`std::thread::id` so you don't need to format it via `std::ostream`.
- Deprecated implicit conversions of unscoped enums to integers for consistency
with scoped enums.
- Added an argument-dependent lookup based `format_as` extension API to
simplify formatting of enums.
- Added experimental `std::variant` formatting support
(`#2941 `\_).
For example (`godbolt `\__):
.. code:: c++
\#include
\#include \
int main() {
auto v = std::variant\(42);
fmt::print("{}\n", v);
}
prints::
variant(42)
Thanks `@jehelset `\_.
- Added experimental `std::filesystem::path` formatting support
(`#2865 `*,
`#2902 `*,
`#2917 `*,
`#2918 `*).
For example (`godbolt `\__):
.. code:: c++
\#include
\#include \
int main() {
fmt::print("There is no place like {}.", std::filesystem::path("/home"));
}
prints::
There is no place like "/home".
Thanks `@phprus (Vladislav Shchapov) `\_.
- Added a `std::thread::id` formatter to `fmt/std.h`.
For example (`godbolt `\__):
.. code:: c++
\#include
\#include \
int main() {
fmt::print("Current thread id: {}\n", std::this_thread::get_id());
}
- Added `fmt::styled` that applies a text style to an individual argument
(`#2793 `\_).
For example (`godbolt `\__):
.. code:: c++
\#include \
\#include \
int main() {
auto now = std::chrono::system_clock::now();
fmt::print(
"\[{}] {}: {}\n",
fmt::styled(now, fmt::emphasis::bold),
fmt::styled("error", fg(fmt::color::red)),
"something went wrong");
}
prints
.. image:: https://user-images.githubusercontent.com/576385/
[`1750712`](https://togithub.com/fmtlib/fmt/commit/175071215)-12809244-dab0-4005-96d8-7cd911c964d5.png
Thanks `@rbrugo (Riccardo Brugo) `\_.
- Made `fmt::print` overload for text styles correctly handle UTF-8
(`#2681 `*,
`#2701 `*).
Thanks `@AlexGuteniev (Alex Guteniev) `\_.
- Fixed Unicode handling when writing to an ostream.
- Added support for nested specifiers to range formatting
(`#2673 `\_).
For example (`godbolt `\__):
.. code:: c++
\#include
\#include \
int main() {
fmt::print("{::#x}\n", std::vector{10, 20, 30});
}
prints `[0xa, 0x14, 0x1e]`.
Thanks `@BRevzin (Barry Revzin) `\_.
- Implemented escaping of wide strings in ranges
(`#2904 `*).
Thanks `@phprus (Vladislav Shchapov) `*.
- Added support for ranges with `begin` / `end` found via the
argument-dependent lookup
(`#2807 `*).
Thanks `@rbrugo (Riccardo Brugo) `*.
- Fixed formatting of certain kinds of ranges of ranges
(`#2787 `*).
Thanks `@BRevzin (Barry Revzin) `*.
- Fixed handling of maps with element types other than `std::pair`
(`#2944 `*).
Thanks `@BrukerJWD (Jonathan W) `*.
- Made tuple formatter enabled only if elements are formattable
(`#2939 `*,
`#2940 `*).
Thanks `@jehelset `\_.
- Made `fmt::join` compatible with format string compilation
(`#2719 `*,
`#2720 `*).
Thanks `@phprus (Vladislav Shchapov) `\_.
- Made compile-time checks work with named arguments of custom types and
`std::ostream` `print` overloads
(`#2816 `*,
`#2817 `*,
`#2819 `*).
Thanks `@timsong-cpp `*.
- Removed `make_args_checked` because it is no longer needed for compile-time
checks (`#2760 `*).
Thanks `@phprus (Vladislav Shchapov) `*.
- Removed the following deprecated APIs: `_format`, `arg_join`,
the `format_to` overload that takes a memory buffer,
`[v]fprintf` that takes an `ostream`.
- Removed the deprecated implicit conversion of `[const] signed char*` and
`[const] unsigned char*` to C strings.
- Removed the deprecated `fmt/locale.h`.
- Replaced the deprecated `fileno()` with `descriptor()` in
`buffered_file`.
- Moved `to_string_view` to the `detail` namespace since it's an
implementation detail.
- Made access mode of a created file consistent with `fopen` by setting
`S_IWGRP` and `S_IWOTH`
(`#2733 `*).
Thanks `@arogge (Andreas Rogge) `*.
- Removed a redundant buffer resize when formatting to `std::ostream`
(`#2842 `*,
`#2843 `*).
Thanks `@jcelerier (Jean-Michaël Celerier) `\_.
- Made precision computation for strings consistent with width
(`#2888 `\_).
- Fixed handling of locale separators in floating point formatting
(`#2830 `\_).
- Made sign specifiers work with `__int128_t`
(`#2773 `\_).
- Improved support for systems such as CHERI with extra data stored in pointers
(`#2932 `*).
Thanks `@davidchisnall (David Chisnall) `*.
- Improved documentation
(`#2706 `*,
`#2712 `*,
`#2789 `*,
`#2803 `*,
`#2805 `*,
`#2815 `*,
`#2924 `*).
Thanks `@BRevzin (Barry Revzin) `*,
`@Pokechu22 `*,
`@setoye (Alta) `*,
`@rtobar `*,
`@rbrugo (Riccardo Brugo) `*,
`@anoonD (cre) `*,
`@leha-bot (Alex) `*.
- Improved build configuration
(`#2766 `*,
`#2772 `*,
`#2836 `*,
`#2852 `*,
`#2907 `*,
`#2913 `*,
`#2914 `*).
Thanks `@kambala-decapitator (Andrey Filipenkov) `*,
`@mattiasljungstrom (Mattias Ljungström) `*,
`@kieselnb (Nick Kiesel) `*,
`@nathannaveen `*,
`@Vertexwahn `*.
- Fixed various warnings and compilation issues
(`#2408 `*,
`#2507 `*,
`#2697 `*,
`#2715 `*,
`#2717 `*,
`#2722 `*,
`#2724 `*,
`#2725 `*,
`#2726 `*,
`#2728 `*,
`#2732 `*,
`#2738 `*,
`#2742 `*,
`#2744 `*,
`#2745 `*,
`#2746 `*,
`#2754 `*,
`#2755 `*,
`#2757 `*,
`#2758 `*,
`#2761 `*,
`#2762 `*,
`#2763 `*,
`#2765 `*,
`#2769 `*,
`#2770 `*,
`#2771 `*,
`#2777 `*,
`#2779 `*,
`#2782 `*,
`#2783 `*,
`#2794 `*,
`#2796 `*,
`#2797 `*,
`#2801 `*,
`#2802 `*,
`#2808 `*,
`#2818 `*,
`#2819 `*,
`#2829 `*,
`#2835 `*,
`#2848 `*,
`#2860 `*,
`#2861 `*,
`#2882 `*,
`#2886 `*,
`#2891 `*,
`#2892 `*,
`#2895 `*,
`#2896 `*,
`#2903 `*,
`#2906 `*,
`#2908 `*,
`#2909 `*,
`#2920 `*,
`#2922 `*,
`#2927 `*,
`#2929 `*,
`#2936 `*,
`#2937 `*,
`#2938 `*,
`#2951 `*,
`#2954 `*,
`#2957 `*,
`#2958 `*,
`#2960 `*).
Thanks `@matrackif `\_
`@Tobi823 (Tobias Hellmann) `*,
`@ivan-volnov (Ivan Volnov) `*,
`@VasiliPupkin256 `*,
`@federico-busato (Federico) `*,
`@barcharcraz (Charlie Barto) `*,
`@jk-jeon (Junekey Jeon) `*,
`@HazardyKnusperkeks (Björn Schäpers) `*,
`@dalboris (Boris Dalstein) `*,
`@seanm (Sean McBride) `*,
`@gsjaardema (Greg Sjaardema) `*,
`@timsong-cpp `*,
`@seanm (Sean McBride) `*,
`@frithrah `*,
`@chronoxor (Ivan Shynkarenka)
This PR contains the following updates:
8.1.1
->9.1.0
Release Notes
fmtlib/fmt
### [`v9.1.0`](https://togithub.com/fmtlib/fmt/blob/HEAD/ChangeLog.rst#910---2022-08-27) [Compare Source](https://togithub.com/fmtlib/fmt/compare/9.0.0...9.1.0) - `fmt::formatted_size` now works at compile time (`#3026