Skip to content
Snippets Groups Projects
Commit c078f5b2 authored by Timo Koch's avatar Timo Koch
Browse files

[fmt] Update shipped version to 9.1.0

parent bdf50688
No related branches found
No related tags found
1 merge request!3362[fmt] Update shipped version to 9.1.0
{fmt} .. image:: https://user-images.githubusercontent.com/
===== 576385/156254208-f5b743a9-88cf-439d-b0c0-923d53e8d551.png
:width: 25%
:alt: {fmt}
.. image:: https://github.com/fmtlib/fmt/workflows/linux/badge.svg
:target: https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux
.. image:: https://travis-ci.org/fmtlib/fmt.png?branch=master .. image:: https://github.com/fmtlib/fmt/workflows/macos/badge.svg
:target: https://travis-ci.org/fmtlib/fmt :target: https://github.com/fmtlib/fmt/actions?query=workflow%3Amacos
.. image:: https://ci.appveyor.com/api/projects/status/ehjkiefde6gucy1v .. image:: https://github.com/fmtlib/fmt/workflows/windows/badge.svg
:target: https://ci.appveyor.com/project/vitaut/fmt :target: https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows
.. image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg .. image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/fmt.svg
:alt: fmt is continuously fuzzed at oss-fuzz :alt: fmt is continuously fuzzed at oss-fuzz
...@@ -20,12 +25,13 @@ ...@@ -20,12 +25,13 @@
**{fmt}** is an open-source formatting library providing a fast and safe **{fmt}** is an open-source formatting library providing a fast and safe
alternative to C stdio and C++ iostreams. alternative to C stdio and C++ iostreams.
If you like this project, please consider donating to BYSOL, If you like this project, please consider donating to one of the funds that
an initiative to help victims of political repressions in Belarus: help victims of the war in Ukraine: https://www.stopputin.net/.
https://www.facebook.com/donate/759400044849707/108388587646909/.
`Documentation <https://fmt.dev>`__ `Documentation <https://fmt.dev>`__
`Cheat Sheets <https://hackingcpp.com/cpp/libs/fmt.html>`__
Q&A: ask questions on `StackOverflow with the tag fmt Q&A: ask questions on `StackOverflow with the tag fmt
<https://stackoverflow.com/questions/tagged/fmt>`_. <https://stackoverflow.com/questions/tagged/fmt>`_.
...@@ -81,7 +87,7 @@ Examples ...@@ -81,7 +87,7 @@ Examples
.. code:: c++ .. code:: c++
#include <fmt/core.h> #include <fmt/core.h>
int main() { int main() {
fmt::print("Hello, world!\n"); fmt::print("Hello, world!\n");
} }
...@@ -117,7 +123,7 @@ Output:: ...@@ -117,7 +123,7 @@ Output::
Default format: 42s 100ms Default format: 42s 100ms
strftime-like format: 03:15:30 strftime-like format: 03:15:30
**Print a container** (`run <https://godbolt.org/z/MjsY7c>`_) **Print a container** (`run <https://godbolt.org/z/MxM1YqjE7>`_)
.. code:: c++ .. code:: c++
...@@ -131,16 +137,16 @@ Output:: ...@@ -131,16 +137,16 @@ Output::
Output:: Output::
{1, 2, 3} [1, 2, 3]
**Check a format string at compile time** **Check a format string at compile time**
.. code:: c++ .. code:: c++
std::string s = fmt::format(FMT_STRING("{:d}"), "don't panic"); std::string s = fmt::format("{:d}", "I am not a number");
This gives a compile-time error because ``d`` is an invalid format specifier for This gives a compile-time error in C++20 because ``d`` is an invalid format
a string. specifier for a string.
**Write a file from a single thread** **Write a file from a single thread**
...@@ -199,7 +205,7 @@ The above results were generated by building ``tinyformat_test.cpp`` on macOS ...@@ -199,7 +205,7 @@ The above results were generated by building ``tinyformat_test.cpp`` on macOS
best of three runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"`` best of three runs. In the test, the format string ``"%0.10f:%04d:%+g:%s:%p:%c:%%\n"``
or equivalent is filled 2,000,000 times with output sent to ``/dev/null``; for or equivalent is filled 2,000,000 times with output sent to ``/dev/null``; for
further details refer to the `source further details refer to the `source
<https://github.com/fmtlib/format-benchmark/blob/master/tinyformat_test.cpp>`_. <https://github.com/fmtlib/format-benchmark/blob/master/src/tinyformat-test.cc>`_.
{fmt} is up to 20-30x faster than ``std::ostringstream`` and ``sprintf`` on {fmt} is up to 20-30x faster than ``std::ostringstream`` and ``sprintf`` on
floating-point formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_) floating-point formatting (`dtoa-benchmark <https://github.com/fmtlib/dtoa-benchmark>`_)
...@@ -284,23 +290,32 @@ or the bloat test:: ...@@ -284,23 +290,32 @@ or the bloat test::
$ make bloat-test $ make bloat-test
Migrating code
--------------
`clang-tidy-fmt <https://github.com/mikecrowe/clang-tidy-fmt>`_ provides clang
tidy checks for converting occurrences of ``printf`` and ``fprintf`` to
``fmt::print``.
Projects using this library Projects using this library
--------------------------- ---------------------------
* `0 A.D. <https://play0ad.com/>`_: a free, open-source, cross-platform * `0 A.D. <https://play0ad.com/>`_: a free, open-source, cross-platform
real-time strategy game real-time strategy game
* `2GIS <https://2gis.ru/>`_: free business listings with a city map
* `AMPL/MP <https://github.com/ampl/mp>`_: * `AMPL/MP <https://github.com/ampl/mp>`_:
an open-source library for mathematical programming an open-source library for mathematical programming
* `Aseprite <https://github.com/aseprite/aseprite>`_: * `Aseprite <https://github.com/aseprite/aseprite>`_:
animated sprite editor & pixel art tool animated sprite editor & pixel art tool
* `AvioBook <https://www.aviobook.aero/en>`_: a comprehensive aircraft * `AvioBook <https://www.aviobook.aero/en>`_: a comprehensive aircraft
operations suite operations suite
* `Blizzard Battle.net <https://battle.net/>`_: an online gaming platform * `Blizzard Battle.net <https://battle.net/>`_: an online gaming platform
* `Celestia <https://celestia.space/>`_: real-time 3D visualization of space * `Celestia <https://celestia.space/>`_: real-time 3D visualization of space
* `Ceph <https://ceph.com/>`_: a scalable distributed storage system * `Ceph <https://ceph.com/>`_: a scalable distributed storage system
...@@ -310,7 +325,7 @@ Projects using this library ...@@ -310,7 +325,7 @@ Projects using this library
* `ClickHouse <https://github.com/ClickHouse/ClickHouse>`_: analytical database * `ClickHouse <https://github.com/ClickHouse/ClickHouse>`_: analytical database
management system management system
* `CUAUV <http://cuauv.org/>`_: Cornell University's autonomous underwater * `CUAUV <https://cuauv.org/>`_: Cornell University's autonomous underwater
vehicle vehicle
* `Drake <https://drake.mit.edu/>`_: a planning, control, and analysis toolbox * `Drake <https://drake.mit.edu/>`_: a planning, control, and analysis toolbox
...@@ -321,8 +336,18 @@ Projects using this library ...@@ -321,8 +336,18 @@ Projects using this library
* `FiveM <https://fivem.net/>`_: a modification framework for GTA V * `FiveM <https://fivem.net/>`_: a modification framework for GTA V
* `fmtlog <https://github.com/MengRao/fmtlog>`_: a performant fmtlib-style
logging library with latency in nanoseconds
* `Folly <https://github.com/facebook/folly>`_: Facebook open-source library * `Folly <https://github.com/facebook/folly>`_: Facebook open-source library
* `GemRB <https://gemrb.org/>`_: a portable open-source implementation of
Bioware’s Infinity Engine
* `Grand Mountain Adventure
<https://store.steampowered.com/app/1247360/Grand_Mountain_Adventure/>`_:
a beautiful open-world ski & snowboarding game
* `HarpyWar/pvpgn <https://github.com/pvpgn/pvpgn-server>`_: * `HarpyWar/pvpgn <https://github.com/pvpgn/pvpgn-server>`_:
Player vs Player Gaming Network with tweaks Player vs Player Gaming Network with tweaks
...@@ -354,7 +379,7 @@ Projects using this library ...@@ -354,7 +379,7 @@ Projects using this library
* `quasardb <https://www.quasardb.net/>`_: a distributed, high-performance, * `quasardb <https://www.quasardb.net/>`_: a distributed, high-performance,
associative database associative database
* `Quill <https://github.com/odygrd/quill>`_: asynchronous low-latency logging library * `Quill <https://github.com/odygrd/quill>`_: asynchronous low-latency logging library
* `QKW <https://github.com/ravijanjam/qkw>`_: generalizing aliasing to simplify * `QKW <https://github.com/ravijanjam/qkw>`_: generalizing aliasing to simplify
...@@ -447,7 +472,7 @@ Boost Format ...@@ -447,7 +472,7 @@ Boost Format
This is a very powerful library which supports both ``printf``-like format This is a very powerful library which supports both ``printf``-like format
strings and positional arguments. Its main drawback is performance. According to strings and positional arguments. Its main drawback is performance. According to
various, benchmarks it is much slower than other methods considered here. Boost various benchmarks, it is much slower than other methods considered here. Boost
Format also has excessive build times and severe code bloat issues (see Format also has excessive build times and severe code bloat issues (see
`Benchmarks`_). `Benchmarks`_).
......
7.1.0 9.1.0
This diff is collapsed.
This diff is collapsed.
...@@ -10,60 +10,38 @@ ...@@ -10,60 +10,38 @@
FMT_BEGIN_NAMESPACE FMT_BEGIN_NAMESPACE
namespace detail { namespace detail {
template <typename T> template FMT_API auto dragonbox::to_decimal(float x) noexcept
int format_float(char* buf, std::size_t size, const char* format, int precision, -> dragonbox::decimal_fp<float>;
T value) { template FMT_API auto dragonbox::to_decimal(double x) noexcept
#ifdef FMT_FUZZ -> dragonbox::decimal_fp<double>;
if (precision > 100000)
throw std::runtime_error(
"fuzz mode - avoid large allocation inside snprintf");
#endif
// Suppress the warning about nonliteral format string.
int (*snprintf_ptr)(char*, size_t, const char*, ...) = FMT_SNPRINTF;
return precision < 0 ? snprintf_ptr(buf, size, format, value)
: snprintf_ptr(buf, size, format, precision, value);
}
} // namespace detail
template struct FMT_INSTANTIATION_DEF_API detail::basic_data<void>;
// Workaround a bug in MSVC2013 that prevents instantiation of format_float.
int (*instantiate_format_float)(double, int, detail::float_specs,
detail::buffer<char>&) = detail::format_float;
#ifndef FMT_STATIC_THOUSANDS_SEPARATOR #ifndef FMT_STATIC_THOUSANDS_SEPARATOR
template FMT_API detail::locale_ref::locale_ref(const std::locale& loc); template FMT_API locale_ref::locale_ref(const std::locale& loc);
template FMT_API std::locale detail::locale_ref::get<std::locale>() const; template FMT_API auto locale_ref::get<std::locale>() const -> std::locale;
#endif #endif
// Explicit instantiations for char. // Explicit instantiations for char.
template FMT_API std::string detail::grouping_impl<char>(locale_ref); template FMT_API auto thousands_sep_impl(locale_ref)
template FMT_API char detail::thousands_sep_impl(locale_ref); -> thousands_sep_result<char>;
template FMT_API char detail::decimal_point_impl(locale_ref); template FMT_API auto decimal_point_impl(locale_ref) -> char;
template FMT_API void detail::buffer<char>::append(const char*, const char*); template FMT_API void buffer<char>::append(const char*, const char*);
template FMT_API void detail::vformat_to( // DEPRECATED!
detail::buffer<char>&, string_view, // There is no correspondent extern template in format.h because of
basic_format_args<FMT_BUFFER_CONTEXT(char)>, detail::locale_ref); // incompatibility between clang and gcc (#2377).
template FMT_API void vformat_to(buffer<char>&, string_view,
template FMT_API int detail::snprintf_float(double, int, detail::float_specs, basic_format_args<FMT_BUFFER_CONTEXT(char)>,
detail::buffer<char>&); locale_ref);
template FMT_API int detail::snprintf_float(long double, int,
detail::float_specs,
detail::buffer<char>&);
template FMT_API int detail::format_float(double, int, detail::float_specs,
detail::buffer<char>&);
template FMT_API int detail::format_float(long double, int, detail::float_specs,
detail::buffer<char>&);
// Explicit instantiations for wchar_t. // Explicit instantiations for wchar_t.
template FMT_API std::string detail::grouping_impl<wchar_t>(locale_ref); template FMT_API auto thousands_sep_impl(locale_ref)
template FMT_API wchar_t detail::thousands_sep_impl(locale_ref); -> thousands_sep_result<wchar_t>;
template FMT_API wchar_t detail::decimal_point_impl(locale_ref); template FMT_API auto decimal_point_impl(locale_ref) -> wchar_t;
template FMT_API void buffer<wchar_t>::append(const wchar_t*, const wchar_t*);
template FMT_API void detail::buffer<wchar_t>::append(const wchar_t*, } // namespace detail
const wchar_t*);
FMT_END_NAMESPACE FMT_END_NAMESPACE
This diff is collapsed.
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment