diff --git a/Makefile.am b/Makefile.am
index a43f0fd..f94c6f4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,6 +17,7 @@ AM_CPPFLAGS = \
-I $(top_builddir)/src \
-I $(top_srcdir)/src \
-I $(top_srcdir)/libs/miniaudio \
+-I $(top_srcdir)/libs \
-DPKGDATADIR="\"$(pkgdatadir)/\"" \
$(SIDPLAYFP_CFLAGS) \
$(STILVIEW_CFLAGS) \
@@ -28,10 +29,31 @@ bin_PROGRAMS = \
src/sidplayfp \
src/stilview
+#=========================================================
+#fmt
+fmt_SOURCES = \
+libs/fmt/args.h \
+libs/fmt/base.h \
+libs/fmt/chrono.h \
+libs/fmt/color.h \
+libs/fmt/compile.h \
+libs/fmt/core.h \
+libs/fmt/format-inl.h \
+libs/fmt/format.cc \
+libs/fmt/format.h \
+libs/fmt/os.cc \
+libs/fmt/os.h \
+libs/fmt/ostream.h \
+libs/fmt/printf.h \
+libs/fmt/ranges.h \
+libs/fmt/std.h \
+libs/fmt/xchar.h
+
#=========================================================
# sidplayfp
src_sidplayfp_SOURCES = \
+$(fmt_SOURCES) \
libs/miniaudio/osaudio_miniaudio.c \
libs/miniaudio/osaudio.h \
libs/miniaudio/miniaudio.h \
@@ -83,6 +105,7 @@ $(W32_LIBS)
# stilview
src_stilview_SOURCES = \
+$(fmt_SOURCES) \
src/codeConvert.cpp \
src/codeConvert.h \
$(ICONV_SOURCES) \
diff --git a/libs/fmt/LICENSE b/libs/fmt/LICENSE
new file mode 100644
index 0000000..1cd1ef9
--- /dev/null
+++ b/libs/fmt/LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2012 - present, Victor Zverovich and {fmt} contributors
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+--- Optional exception to the license ---
+
+As an exception, if, as a result of your compiling your source code, portions
+of this Software are embedded into a machine-executable object form of such
+source code, you may redistribute such embedded portions in such object form
+without including the above copyright and permission notices.
diff --git a/libs/fmt/README.md b/libs/fmt/README.md
new file mode 100644
index 0000000..612c10c
--- /dev/null
+++ b/libs/fmt/README.md
@@ -0,0 +1,486 @@
+
+
+[](https://github.com/fmtlib/fmt/actions?query=workflow%3Alinux)
+[](https://github.com/fmtlib/fmt/actions?query=workflow%3Amacos)
+[](https://github.com/fmtlib/fmt/actions?query=workflow%3Awindows)
+[](https://bugs.chromium.org/p/oss-fuzz/issues/list?\%0Acolspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20\%0ASummary&q=proj%3Dfmt&can=1)
+[](https://www.bestpractices.dev/projects/8880)
+[](https://securityscorecards.dev/viewer/?uri=github.com/fmtlib/fmt)
+[](https://stackoverflow.com/questions/tagged/fmt)
+
+**{fmt}** is an open-source formatting library providing a fast and safe
+alternative to C stdio and C++ iostreams.
+
+If you like this project, please consider donating to one of the funds
+that help victims of the war in Ukraine: .
+
+[Documentation](https://fmt.dev)
+
+[Cheat Sheets](https://hackingcpp.com/cpp/libs/fmt.html)
+
+Q&A: ask questions on [StackOverflow with the tag
+fmt](https://stackoverflow.com/questions/tagged/fmt).
+
+Try {fmt} in [Compiler Explorer](https://godbolt.org/z/8Mx1EW73v).
+
+# Features
+
+- Simple [format API](https://fmt.dev/latest/api/) with positional
+ arguments for localization
+- Implementation of [C++20
+ std::format](https://en.cppreference.com/w/cpp/utility/format) and
+ [C++23 std::print](https://en.cppreference.com/w/cpp/io/print)
+- [Format string syntax](https://fmt.dev/latest/syntax/) similar
+ to Python\'s
+ [format](https://docs.python.org/3/library/stdtypes.html#str.format)
+- Fast IEEE 754 floating-point formatter with correct rounding,
+ shortness and round-trip guarantees using the
+ [Dragonbox](https://github.com/jk-jeon/dragonbox) algorithm
+- Portable Unicode support
+- Safe [printf
+ implementation](https://fmt.dev/latest/api/#printf-formatting)
+ including the POSIX extension for positional arguments
+- Extensibility: [support for user-defined
+ types](https://fmt.dev/latest/api/#formatting-user-defined-types)
+- High performance: faster than common standard library
+ implementations of `(s)printf`, iostreams, `to_string` and
+ `to_chars`, see [Speed tests](#speed-tests) and [Converting a
+ hundred million integers to strings per
+ second](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html)
+- Small code size both in terms of source code with the minimum
+ configuration consisting of just three files, `base.h`, `format.h`
+ and `format-inl.h`, and compiled code; see [Compile time and code
+ bloat](#compile-time-and-code-bloat)
+- Reliability: the library has an extensive set of
+ [tests](https://github.com/fmtlib/fmt/tree/master/test) and is
+ [continuously fuzzed](https://bugs.chromium.org/p/oss-fuzz/issues/list?colspec=ID%20Type%20Component%20Status%20Proj%20Reported%20Owner%20Summary&q=proj%3Dfmt&can=1)
+- Safety: the library is fully type-safe, errors in format strings can
+ be reported at compile time, automatic memory management prevents
+ buffer overflow errors
+- Ease of use: small self-contained code base, no external
+ dependencies, permissive MIT
+ [license](https://github.com/fmtlib/fmt/blob/master/LICENSE)
+- [Portability](https://fmt.dev/latest/#portability) with
+ consistent output across platforms and support for older compilers
+- Clean warning-free codebase even on high warning levels such as
+ `-Wall -Wextra -pedantic`
+- Locale independence by default
+- Optional header-only configuration enabled with the
+ `FMT_HEADER_ONLY` macro
+
+See the [documentation](https://fmt.dev) for more details.
+
+# Examples
+
+**Print to stdout** ([run](https://godbolt.org/z/Tevcjh))
+
+``` c++
+#include
+
+int main() {
+ fmt::print("Hello, world!\n");
+}
+```
+
+**Format a string** ([run](https://godbolt.org/z/oK8h33))
+
+``` c++
+std::string s = fmt::format("The answer is {}.", 42);
+// s == "The answer is 42."
+```
+
+**Format a string using positional arguments**
+([run](https://godbolt.org/z/Yn7Txe))
+
+``` c++
+std::string s = fmt::format("I'd rather be {1} than {0}.", "right", "happy");
+// s == "I'd rather be happy than right."
+```
+
+**Print dates and times** ([run](https://godbolt.org/z/c31ExdY3W))
+
+``` c++
+#include
+
+int main() {
+ auto now = std::chrono::system_clock::now();
+ fmt::print("Date and time: {}\n", now);
+ fmt::print("Time: {:%H:%M}\n", now);
+}
+```
+
+Output:
+
+ Date and time: 2023-12-26 19:10:31.557195597
+ Time: 19:10
+
+**Print a container** ([run](https://godbolt.org/z/MxM1YqjE7))
+
+``` c++
+#include
+#include
+
+int main() {
+ std::vector v = {1, 2, 3};
+ fmt::print("{}\n", v);
+}
+```
+
+Output:
+
+ [1, 2, 3]
+
+**Check a format string at compile time**
+
+``` c++
+std::string s = fmt::format("{:d}", "I am not a number");
+```
+
+This gives a compile-time error in C++20 because `d` is an invalid
+format specifier for a string.
+
+**Write a file from a single thread**
+
+``` c++
+#include
+
+int main() {
+ auto out = fmt::output_file("guide.txt");
+ out.print("Don't {}", "Panic");
+}
+```
+
+This can be [5 to 9 times faster than
+fprintf](http://www.zverovich.net/2020/08/04/optimal-file-buffer-size.html).
+
+**Print with colors and text styles**
+
+``` c++
+#include
+
+int main() {
+ fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold,
+ "Hello, {}!\n", "world");
+ fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) |
+ fmt::emphasis::underline, "Olá, {}!\n", "Mundo");
+ fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic,
+ "你好{}!\n", "世界");
+}
+```
+
+Output on a modern terminal with Unicode support:
+
+
+
+# Benchmarks
+
+## Speed tests
+
+| Library | Method | Run Time, s |
+|-------------------|---------------|-------------|
+| libc | printf | 0.91 |
+| libc++ | std::ostream | 2.49 |
+| {fmt} 9.1 | fmt::print | 0.74 |
+| Boost Format 1.80 | boost::format | 6.26 |
+| Folly Format | folly::format | 1.87 |
+
+{fmt} is the fastest of the benchmarked methods, \~20% faster than
+`printf`.
+
+The above results were generated by building `tinyformat_test.cpp` on
+macOS 12.6.1 with `clang++ -O3 -DNDEBUG -DSPEED_TEST -DHAVE_FORMAT`, and
+taking the 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 further details refer to the
+[source](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
+IEEE754 `float` and `double` formatting
+([dtoa-benchmark](https://github.com/fmtlib/dtoa-benchmark)) and faster
+than [double-conversion](https://github.com/google/double-conversion)
+and [ryu](https://github.com/ulfjack/ryu):
+
+[](https://fmt.dev/unknown_mac64_clang12.0.html)
+
+## Compile time and code bloat
+
+The script [bloat-test.py][test] from [format-benchmark][bench] tests compile
+time and code bloat for nontrivial projects. It generates 100 translation units
+and uses `printf()` or its alternative five times in each to simulate a
+medium-sized project. The resulting executable size and compile time (Apple
+clang version 15.0.0 (clang-1500.1.0.2.5), macOS Sonoma, best of three) is shown
+in the following tables.
+
+[test]: https://github.com/fmtlib/format-benchmark/blob/master/bloat-test.py
+[bench]: https://github.com/fmtlib/format-benchmark
+
+**Optimized build (-O3)**
+
+| Method | Compile Time, s | Executable size, KiB | Stripped size, KiB |
+|---------------|-----------------|----------------------|--------------------|
+| printf | 1.6 | 54 | 50 |
+| IOStreams | 25.9 | 98 | 84 |
+| fmt 83652df | 4.8 | 54 | 50 |
+| tinyformat | 29.1 | 161 | 136 |
+| Boost Format | 55.0 | 530 | 317 |
+
+{fmt} is fast to compile and is comparable to `printf` in terms of per-call
+binary size (within a rounding error on this system).
+
+**Non-optimized build**
+
+| Method | Compile Time, s | Executable size, KiB | Stripped size, KiB |
+|---------------|-----------------|----------------------|--------------------|
+| printf | 1.4 | 54 | 50 |
+| IOStreams | 23.4 | 92 | 68 |
+| {fmt} 83652df | 4.4 | 89 | 85 |
+| tinyformat | 24.5 | 204 | 161 |
+| Boost Format | 36.4 | 831 | 462 |
+
+`libc`, `lib(std)c++`, and `libfmt` are all linked as shared libraries
+to compare formatting function overhead only. Boost Format is a
+header-only library so it doesn\'t provide any linkage options.
+
+## Running the tests
+
+Please refer to [Building the
+library](https://fmt.dev/latest/get-started/#building-from-source) for
+instructions on how to build the library and run the unit tests.
+
+Benchmarks reside in a separate repository,
+[format-benchmarks](https://github.com/fmtlib/format-benchmark), so to
+run the benchmarks you first need to clone this repository and generate
+Makefiles with CMake:
+
+ $ git clone --recursive https://github.com/fmtlib/format-benchmark.git
+ $ cd format-benchmark
+ $ cmake .
+
+Then you can run the speed test:
+
+ $ make speed-test
+
+or the bloat test:
+
+ $ make bloat-test
+
+# Migrating code
+
+[clang-tidy](https://clang.llvm.org/extra/clang-tidy/) v18 provides the
+[modernize-use-std-print](https://clang.llvm.org/extra/clang-tidy/checks/modernize/use-std-print.html)
+check that is capable of converting occurrences of `printf` and
+`fprintf` to `fmt::print` if configured to do so. (By default it
+converts to `std::print`.)
+
+# Notable projects using this library
+
+- [0 A.D.](https://play0ad.com/): a free, open-source, cross-platform
+ real-time strategy game
+- [AMPL/MP](https://github.com/ampl/mp): an open-source library for
+ mathematical programming
+- [Apple's FoundationDB](https://github.com/apple/foundationdb): an open-source,
+ distributed, transactional key-value store
+- [Aseprite](https://github.com/aseprite/aseprite): animated sprite
+ editor & pixel art tool
+- [AvioBook](https://www.aviobook.aero/en): a comprehensive aircraft
+ operations suite
+- [Blizzard Battle.net](https://battle.net/): an online gaming
+ platform
+- [Celestia](https://celestia.space/): real-time 3D visualization of
+ space
+- [Ceph](https://ceph.com/): a scalable distributed storage system
+- [ccache](https://ccache.dev/): a compiler cache
+- [ClickHouse](https://github.com/ClickHouse/ClickHouse): an
+ analytical database management system
+- [ContextVision](https://www.contextvision.com/): medical imaging software
+- [Contour](https://github.com/contour-terminal/contour/): a modern
+ terminal emulator
+- [CUAUV](https://cuauv.org/): Cornell University\'s autonomous
+ underwater vehicle
+- [Drake](https://drake.mit.edu/): a planning, control, and analysis
+ toolbox for nonlinear dynamical systems (MIT)
+- [Envoy](https://github.com/envoyproxy/envoy): C++ L7 proxy and
+ communication bus (Lyft)
+- [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
+- [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): Player vs
+ Player Gaming Network with tweaks
+- [KBEngine](https://github.com/kbengine/kbengine): an open-source
+ MMOG server engine
+- [Keypirinha](https://keypirinha.com/): a semantic launcher for
+ Windows
+- [Kodi](https://kodi.tv/) (formerly xbmc): home theater software
+- [Knuth](https://kth.cash/): high-performance Bitcoin full-node
+- [libunicode](https://github.com/contour-terminal/libunicode/): a
+ modern C++17 Unicode library
+- [MariaDB](https://mariadb.org/): relational database management
+ system
+- [Microsoft Verona](https://github.com/microsoft/verona): research
+ programming language for concurrent ownership
+- [MongoDB](https://mongodb.com/): distributed document database
+- [MongoDB Smasher](https://github.com/duckie/mongo_smasher): a small
+ tool to generate randomized datasets
+- [OpenSpace](https://openspaceproject.com/): an open-source
+ astrovisualization framework
+- [PenUltima Online (POL)](https://www.polserver.com/): an MMO server,
+ compatible with most Ultima Online clients
+- [PyTorch](https://github.com/pytorch/pytorch): an open-source
+ machine learning library
+- [quasardb](https://www.quasardb.net/): a distributed,
+ high-performance, associative database
+- [Quill](https://github.com/odygrd/quill): asynchronous low-latency
+ logging library
+- [QKW](https://github.com/ravijanjam/qkw): generalizing aliasing to
+ simplify navigation, and execute complex multi-line terminal
+ command sequences
+- [redis-cerberus](https://github.com/HunanTV/redis-cerberus): a Redis
+ cluster proxy
+- [redpanda](https://vectorized.io/redpanda): a 10x faster Kafka®
+ replacement for mission-critical systems written in C++
+- [rpclib](http://rpclib.net/): a modern C++ msgpack-RPC server and
+ client library
+- [Salesforce Analytics
+ Cloud](https://www.salesforce.com/analytics-cloud/overview/):
+ business intelligence software
+- [Scylla](https://www.scylladb.com/): a Cassandra-compatible NoSQL
+ data store that can handle 1 million transactions per second on a
+ single server
+- [Seastar](http://www.seastar-project.org/): an advanced, open-source
+ C++ framework for high-performance server applications on modern
+ hardware
+- [spdlog](https://github.com/gabime/spdlog): super fast C++ logging
+ library
+- [Stellar](https://www.stellar.org/): financial platform
+- [Touch Surgery](https://www.touchsurgery.com/): surgery simulator
+- [TrinityCore](https://github.com/TrinityCore/TrinityCore):
+ open-source MMORPG framework
+- [🐙 userver framework](https://userver.tech/): open-source
+ asynchronous framework with a rich set of abstractions and database
+ drivers
+- [Windows Terminal](https://github.com/microsoft/terminal): the new
+ Windows terminal
+
+[More\...](https://github.com/search?q=fmtlib&type=Code)
+
+If you are aware of other projects using this library, please let me
+know by [email](mailto:victor.zverovich@gmail.com) or by submitting an
+[issue](https://github.com/fmtlib/fmt/issues).
+
+# Motivation
+
+So why yet another formatting library?
+
+There are plenty of methods for doing this task, from standard ones like
+the printf family of function and iostreams to Boost Format and
+FastFormat libraries. The reason for creating a new library is that
+every existing solution that I found either had serious issues or
+didn\'t provide all the features I needed.
+
+## printf
+
+The good thing about `printf` is that it is pretty fast and readily
+available being a part of the C standard library. The main drawback is
+that it doesn\'t support user-defined types. `printf` also has safety
+issues although they are somewhat mitigated with [\_\_attribute\_\_
+((format (printf,
+\...))](https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html) in
+GCC. There is a POSIX extension that adds positional arguments required
+for
+[i18n](https://en.wikipedia.org/wiki/Internationalization_and_localization)
+to `printf` but it is not a part of C99 and may not be available on some
+platforms.
+
+## iostreams
+
+The main issue with iostreams is best illustrated with an example:
+
+``` c++
+std::cout << std::setprecision(2) << std::fixed << 1.23456 << "\n";
+```
+
+which is a lot of typing compared to printf:
+
+``` c++
+printf("%.2f\n", 1.23456);
+```
+
+Matthew Wilson, the author of FastFormat, called this \"chevron hell\".
+iostreams don\'t support positional arguments by design.
+
+The good part is that iostreams support user-defined types and are safe
+although error handling is awkward.
+
+## Boost Format
+
+This is a very powerful library that supports both `printf`-like format
+strings and positional arguments. Its main drawback is performance.
+According to various benchmarks, it is much slower than other methods
+considered here. Boost Format also has excessive build times and severe
+code bloat issues (see [Benchmarks](#benchmarks)).
+
+## FastFormat
+
+This is an interesting library that is fast, safe and has positional
+arguments. However, it has significant limitations, citing its author:
+
+> Three features that have no hope of being accommodated within the
+> current design are:
+>
+> - Leading zeros (or any other non-space padding)
+> - Octal/hexadecimal encoding
+> - Runtime width/alignment specification
+
+It is also quite big and has a heavy dependency, on STLSoft, which might be
+too restrictive for use in some projects.
+
+## Boost Spirit.Karma
+
+This is not a formatting library but I decided to include it here for
+completeness. As iostreams, it suffers from the problem of mixing
+verbatim text with arguments. The library is pretty fast, but slower on
+integer formatting than `fmt::format_to` with format string compilation
+on Karma\'s own benchmark, see [Converting a hundred million integers to
+strings per
+second](http://www.zverovich.net/2020/06/13/fast-int-to-string-revisited.html).
+
+# License
+
+{fmt} is distributed under the MIT
+[license](https://github.com/fmtlib/fmt/blob/master/LICENSE).
+
+# Documentation License
+
+The [Format String Syntax](https://fmt.dev/latest/syntax/) section
+in the documentation is based on the one from Python [string module
+documentation](https://docs.python.org/3/library/string.html#module-string).
+For this reason, the documentation is distributed under the Python
+Software Foundation license available in
+[doc/python-license.txt](https://raw.github.com/fmtlib/fmt/master/doc/python-license.txt).
+It only applies if you distribute the documentation of {fmt}.
+
+# Maintainers
+
+The {fmt} library is maintained by Victor Zverovich
+([vitaut](https://github.com/vitaut)) with contributions from many other
+people. See
+[Contributors](https://github.com/fmtlib/fmt/graphs/contributors) and
+[Releases](https://github.com/fmtlib/fmt/releases) for some of the
+names. Let us know if your contribution is not listed or mentioned
+incorrectly and we\'ll make it right.
+
+# Security Policy
+
+To report a security issue, please disclose it at [security
+advisory](https://github.com/fmtlib/fmt/security/advisories/new).
+
+This project is maintained by a team of volunteers on a
+reasonable-effort basis. As such, please give us at least *90* days to
+work on a fix before public exposure.
diff --git a/libs/fmt/args.h b/libs/fmt/args.h
new file mode 100644
index 0000000..5e5f40f
--- /dev/null
+++ b/libs/fmt/args.h
@@ -0,0 +1,220 @@
+// Formatting library for C++ - dynamic argument lists
+//
+// Copyright (c) 2012 - present, Victor Zverovich
+// All rights reserved.
+//
+// For the license information refer to format.h.
+
+#ifndef FMT_ARGS_H_
+#define FMT_ARGS_H_
+
+#ifndef FMT_MODULE
+# include // std::reference_wrapper
+# include // std::unique_ptr
+# include
+#endif
+
+#include "format.h" // std_string_view
+
+FMT_BEGIN_NAMESPACE
+namespace detail {
+
+template struct is_reference_wrapper : std::false_type {};
+template
+struct is_reference_wrapper> : std::true_type {};
+
+template auto unwrap(const T& v) -> const T& { return v; }
+template
+auto unwrap(const std::reference_wrapper& v) -> const T& {
+ return static_cast(v);
+}
+
+// node is defined outside dynamic_arg_list to workaround a C2504 bug in MSVC
+// 2022 (v17.10.0).
+//
+// Workaround for clang's -Wweak-vtables. Unlike for regular classes, for
+// templates it doesn't complain about inability to deduce single translation
+// unit for placing vtable. So node is made a fake template.
+template struct node {
+ virtual ~node() = default;
+ std::unique_ptr> next;
+};
+
+class dynamic_arg_list {
+ template struct typed_node : node<> {
+ T value;
+
+ template
+ FMT_CONSTEXPR typed_node(const Arg& arg) : value(arg) {}
+
+ template
+ FMT_CONSTEXPR typed_node(const basic_string_view& arg)
+ : value(arg.data(), arg.size()) {}
+ };
+
+ std::unique_ptr> head_;
+
+ public:
+ template auto push(const Arg& arg) -> const T& {
+ auto new_node = std::unique_ptr>(new typed_node(arg));
+ auto& value = new_node->value;
+ new_node->next = std::move(head_);
+ head_ = std::move(new_node);
+ return value;
+ }
+};
+} // namespace detail
+
+/**
+ * A dynamic list of formatting arguments with storage.
+ *
+ * It can be implicitly converted into `fmt::basic_format_args` for passing
+ * into type-erased formatting functions such as `fmt::vformat`.
+ */
+FMT_EXPORT template class dynamic_format_arg_store {
+ private:
+ using char_type = typename Context::char_type;
+
+ template struct need_copy {
+ static constexpr detail::type mapped_type =
+ detail::mapped_type_constant::value;
+
+ enum {
+ value = !(detail::is_reference_wrapper::value ||
+ std::is_same>::value ||
+ std::is_same>::value ||
+ (mapped_type != detail::type::cstring_type &&
+ mapped_type != detail::type::string_type &&
+ mapped_type != detail::type::custom_type))
+ };
+ };
+
+ template
+ using stored_t = conditional_t<
+ std::is_convertible>::value &&
+ !detail::is_reference_wrapper::value,
+ std::basic_string, T>;
+
+ // Storage of basic_format_arg must be contiguous.
+ std::vector> data_;
+ std::vector> named_info_;
+
+ // Storage of arguments not fitting into basic_format_arg must grow
+ // without relocation because items in data_ refer to it.
+ detail::dynamic_arg_list dynamic_args_;
+
+ friend class basic_format_args;
+
+ auto data() const -> const basic_format_arg* {
+ return named_info_.empty() ? data_.data() : data_.data() + 1;
+ }
+
+ template void emplace_arg(const T& arg) {
+ data_.emplace_back(arg);
+ }
+
+ template
+ void emplace_arg(const detail::named_arg& arg) {
+ if (named_info_.empty())
+ data_.insert(data_.begin(), basic_format_arg(nullptr, 0));
+ data_.emplace_back(detail::unwrap(arg.value));
+ auto pop_one = [](std::vector>* data) {
+ data->pop_back();
+ };
+ std::unique_ptr>, decltype(pop_one)>
+ guard{&data_, pop_one};
+ named_info_.push_back({arg.name, static_cast(data_.size() - 2u)});
+ data_[0] = {named_info_.data(), named_info_.size()};
+ guard.release();
+ }
+
+ public:
+ constexpr dynamic_format_arg_store() = default;
+
+ operator basic_format_args() const {
+ return basic_format_args(data(), static_cast(data_.size()),
+ !named_info_.empty());
+ }
+
+ /**
+ * Adds an argument into the dynamic store for later passing to a formatting
+ * function.
+ *
+ * Note that custom types and string types (but not string views) are copied
+ * into the store dynamically allocating memory if necessary.
+ *
+ * **Example**:
+ *
+ * fmt::dynamic_format_arg_store store;
+ * store.push_back(42);
+ * store.push_back("abc");
+ * store.push_back(1.5f);
+ * std::string result = fmt::vformat("{} and {} and {}", store);
+ */
+ template void push_back(const T& arg) {
+ if (detail::const_check(need_copy::value))
+ emplace_arg(dynamic_args_.push>(arg));
+ else
+ emplace_arg(detail::unwrap(arg));
+ }
+
+ /**
+ * Adds a reference to the argument into the dynamic store for later passing
+ * to a formatting function.
+ *
+ * **Example**:
+ *
+ * fmt::dynamic_format_arg_store store;
+ * char band[] = "Rolling Stones";
+ * store.push_back(std::cref(band));
+ * band[9] = 'c'; // Changing str affects the output.
+ * std::string result = fmt::vformat("{}", store);
+ * // result == "Rolling Scones"
+ */
+ template void push_back(std::reference_wrapper arg) {
+ static_assert(
+ need_copy::value,
+ "objects of built-in types and string views are always copied");
+ emplace_arg(arg.get());
+ }
+
+ /**
+ * Adds named argument into the dynamic store for later passing to a
+ * formatting function. `std::reference_wrapper` is supported to avoid
+ * copying of the argument. The name is always copied into the store.
+ */
+ template
+ void push_back(const detail::named_arg& arg) {
+ const char_type* arg_name =
+ dynamic_args_.push>(arg.name).c_str();
+ if (detail::const_check(need_copy::value)) {
+ emplace_arg(
+ fmt::arg(arg_name, dynamic_args_.push>(arg.value)));
+ } else {
+ emplace_arg(fmt::arg(arg_name, arg.value));
+ }
+ }
+
+ /// Erase all elements from the store.
+ void clear() {
+ data_.clear();
+ named_info_.clear();
+ dynamic_args_ = {};
+ }
+
+ /// Reserves space to store at least `new_cap` arguments including
+ /// `new_cap_named` named arguments.
+ void reserve(size_t new_cap, size_t new_cap_named) {
+ FMT_ASSERT(new_cap >= new_cap_named,
+ "set of arguments includes set of named arguments");
+ data_.reserve(new_cap);
+ named_info_.reserve(new_cap_named);
+ }
+
+ /// Returns the number of elements in the store.
+ auto size() const noexcept -> size_t { return data_.size(); }
+};
+
+FMT_END_NAMESPACE
+
+#endif // FMT_ARGS_H_
diff --git a/libs/fmt/base.h b/libs/fmt/base.h
new file mode 100644
index 0000000..0d57867
--- /dev/null
+++ b/libs/fmt/base.h
@@ -0,0 +1,3010 @@
+// Formatting library for C++ - the base API for char/UTF-8
+//
+// Copyright (c) 2012 - present, Victor Zverovich
+// All rights reserved.
+//
+// For the license information refer to format.h.
+
+#ifndef FMT_BASE_H_
+#define FMT_BASE_H_
+
+#if defined(FMT_IMPORT_STD) && !defined(FMT_MODULE)
+# define FMT_MODULE
+#endif
+
+#ifndef FMT_MODULE
+# include // CHAR_BIT
+# include // FILE
+# include // memcmp
+
+# include // std::enable_if
+#endif
+
+// The fmt library version in the form major * 10000 + minor * 100 + patch.
+#define FMT_VERSION 120100
+
+// Detect compiler versions.
+#if defined(__clang__) && !defined(__ibmxl__)
+# define FMT_CLANG_VERSION (__clang_major__ * 100 + __clang_minor__)
+#else
+# define FMT_CLANG_VERSION 0
+#endif
+#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
+# define FMT_GCC_VERSION (__GNUC__ * 100 + __GNUC_MINOR__)
+#else
+# define FMT_GCC_VERSION 0
+#endif
+#if defined(__ICL)
+# define FMT_ICC_VERSION __ICL
+#elif defined(__INTEL_COMPILER)
+# define FMT_ICC_VERSION __INTEL_COMPILER
+#else
+# define FMT_ICC_VERSION 0
+#endif
+#if defined(_MSC_VER)
+# define FMT_MSC_VERSION _MSC_VER
+#else
+# define FMT_MSC_VERSION 0
+#endif
+
+// Detect standard library versions.
+#ifdef _GLIBCXX_RELEASE
+# define FMT_GLIBCXX_RELEASE _GLIBCXX_RELEASE
+#else
+# define FMT_GLIBCXX_RELEASE 0
+#endif
+#ifdef _LIBCPP_VERSION
+# define FMT_LIBCPP_VERSION _LIBCPP_VERSION
+#else
+# define FMT_LIBCPP_VERSION 0
+#endif
+
+#ifdef _MSVC_LANG
+# define FMT_CPLUSPLUS _MSVC_LANG
+#else
+# define FMT_CPLUSPLUS __cplusplus
+#endif
+
+// Detect __has_*.
+#ifdef __has_feature
+# define FMT_HAS_FEATURE(x) __has_feature(x)
+#else
+# define FMT_HAS_FEATURE(x) 0
+#endif
+#ifdef __has_include
+# define FMT_HAS_INCLUDE(x) __has_include(x)
+#else
+# define FMT_HAS_INCLUDE(x) 0
+#endif
+#ifdef __has_builtin
+# define FMT_HAS_BUILTIN(x) __has_builtin(x)
+#else
+# define FMT_HAS_BUILTIN(x) 0
+#endif
+#ifdef __has_cpp_attribute
+# define FMT_HAS_CPP_ATTRIBUTE(x) __has_cpp_attribute(x)
+#else
+# define FMT_HAS_CPP_ATTRIBUTE(x) 0
+#endif
+
+#define FMT_HAS_CPP14_ATTRIBUTE(attribute) \
+ (FMT_CPLUSPLUS >= 201402L && FMT_HAS_CPP_ATTRIBUTE(attribute))
+
+#define FMT_HAS_CPP17_ATTRIBUTE(attribute) \
+ (FMT_CPLUSPLUS >= 201703L && FMT_HAS_CPP_ATTRIBUTE(attribute))
+
+// Detect C++14 relaxed constexpr.
+#ifdef FMT_USE_CONSTEXPR
+// Use the provided definition.
+#elif FMT_GCC_VERSION >= 702 && FMT_CPLUSPLUS >= 201402L
+// GCC only allows constexpr member functions in non-literal types since 7.2:
+// https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66297.
+# define FMT_USE_CONSTEXPR 1
+#elif FMT_ICC_VERSION
+# define FMT_USE_CONSTEXPR 0 // https://github.com/fmtlib/fmt/issues/1628
+#elif FMT_HAS_FEATURE(cxx_relaxed_constexpr) || FMT_MSC_VERSION >= 1912
+# define FMT_USE_CONSTEXPR 1
+#else
+# define FMT_USE_CONSTEXPR 0
+#endif
+#if FMT_USE_CONSTEXPR
+# define FMT_CONSTEXPR constexpr
+#else
+# define FMT_CONSTEXPR
+#endif
+
+// Detect consteval, C++20 constexpr extensions and std::is_constant_evaluated.
+#ifdef FMT_USE_CONSTEVAL
+// Use the provided definition.
+#elif !defined(__cpp_lib_is_constant_evaluated)
+# define FMT_USE_CONSTEVAL 0
+#elif FMT_CPLUSPLUS < 201709L
+# define FMT_USE_CONSTEVAL 0
+#elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10
+# define FMT_USE_CONSTEVAL 0
+#elif FMT_LIBCPP_VERSION && FMT_LIBCPP_VERSION < 10000
+# define FMT_USE_CONSTEVAL 0
+#elif defined(__apple_build_version__) && __apple_build_version__ < 14000029L
+# define FMT_USE_CONSTEVAL 0 // consteval is broken in Apple clang < 14.
+#elif FMT_MSC_VERSION && FMT_MSC_VERSION < 1929
+# define FMT_USE_CONSTEVAL 0 // consteval is broken in MSVC VS2019 < 16.10.
+#elif defined(__cpp_consteval)
+# define FMT_USE_CONSTEVAL 1
+#elif FMT_GCC_VERSION >= 1002 || FMT_CLANG_VERSION >= 1101
+# define FMT_USE_CONSTEVAL 1
+#else
+# define FMT_USE_CONSTEVAL 0
+#endif
+#if FMT_USE_CONSTEVAL
+# define FMT_CONSTEVAL consteval
+# define FMT_CONSTEXPR20 constexpr
+#else
+# define FMT_CONSTEVAL
+# define FMT_CONSTEXPR20
+#endif
+
+// Check if exceptions are disabled.
+#ifdef FMT_USE_EXCEPTIONS
+// Use the provided definition.
+#elif defined(__GNUC__) && !defined(__EXCEPTIONS)
+# define FMT_USE_EXCEPTIONS 0
+#elif defined(__clang__) && !defined(__cpp_exceptions)
+# define FMT_USE_EXCEPTIONS 0
+#elif FMT_MSC_VERSION && !_HAS_EXCEPTIONS
+# define FMT_USE_EXCEPTIONS 0
+#else
+# define FMT_USE_EXCEPTIONS 1
+#endif
+#if FMT_USE_EXCEPTIONS
+# define FMT_TRY try
+# define FMT_CATCH(x) catch (x)
+#else
+# define FMT_TRY if (true)
+# define FMT_CATCH(x) if (false)
+#endif
+
+#ifdef FMT_NO_UNIQUE_ADDRESS
+// Use the provided definition.
+#elif FMT_CPLUSPLUS < 202002L
+// Not supported.
+#elif FMT_HAS_CPP_ATTRIBUTE(no_unique_address)
+# define FMT_NO_UNIQUE_ADDRESS [[no_unique_address]]
+// VS2019 v16.10 and later except clang-cl (https://reviews.llvm.org/D110485).
+#elif FMT_MSC_VERSION >= 1929 && !FMT_CLANG_VERSION
+# define FMT_NO_UNIQUE_ADDRESS [[msvc::no_unique_address]]
+#endif
+#ifndef FMT_NO_UNIQUE_ADDRESS
+# define FMT_NO_UNIQUE_ADDRESS
+#endif
+
+#if FMT_HAS_CPP17_ATTRIBUTE(fallthrough)
+# define FMT_FALLTHROUGH [[fallthrough]]
+#elif defined(__clang__)
+# define FMT_FALLTHROUGH [[clang::fallthrough]]
+#elif FMT_GCC_VERSION >= 700 && \
+ (!defined(__EDG_VERSION__) || __EDG_VERSION__ >= 520)
+# define FMT_FALLTHROUGH [[gnu::fallthrough]]
+#else
+# define FMT_FALLTHROUGH
+#endif
+
+// Disable [[noreturn]] on MSVC/NVCC because of bogus unreachable code warnings.
+#if FMT_HAS_CPP_ATTRIBUTE(noreturn) && !FMT_MSC_VERSION && !defined(__NVCC__)
+# define FMT_NORETURN [[noreturn]]
+#else
+# define FMT_NORETURN
+#endif
+
+#ifdef FMT_NODISCARD
+// Use the provided definition.
+#elif FMT_HAS_CPP17_ATTRIBUTE(nodiscard)
+# define FMT_NODISCARD [[nodiscard]]
+#else
+# define FMT_NODISCARD
+#endif
+
+#if FMT_GCC_VERSION || FMT_CLANG_VERSION
+# define FMT_VISIBILITY(value) __attribute__((visibility(value)))
+#else
+# define FMT_VISIBILITY(value)
+#endif
+
+// Detect pragmas.
+#define FMT_PRAGMA_IMPL(x) _Pragma(#x)
+#if FMT_GCC_VERSION >= 504 && !defined(__NVCOMPILER)
+// Workaround a _Pragma bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59884
+// and an nvhpc warning: https://github.com/fmtlib/fmt/pull/2582.
+# define FMT_PRAGMA_GCC(x) FMT_PRAGMA_IMPL(GCC x)
+#else
+# define FMT_PRAGMA_GCC(x)
+#endif
+#if FMT_CLANG_VERSION
+# define FMT_PRAGMA_CLANG(x) FMT_PRAGMA_IMPL(clang x)
+#else
+# define FMT_PRAGMA_CLANG(x)
+#endif
+#if FMT_MSC_VERSION
+# define FMT_MSC_WARNING(...) __pragma(warning(__VA_ARGS__))
+#else
+# define FMT_MSC_WARNING(...)
+#endif
+
+// Enable minimal optimizations for more compact code in debug mode.
+FMT_PRAGMA_GCC(push_options)
+#if !defined(__OPTIMIZE__) && !defined(__CUDACC__) && !defined(FMT_MODULE)
+FMT_PRAGMA_GCC(optimize("Og"))
+# define FMT_GCC_OPTIMIZED
+#endif
+FMT_PRAGMA_CLANG(diagnostic push)
+FMT_PRAGMA_GCC(diagnostic push)
+
+#ifdef FMT_ALWAYS_INLINE
+// Use the provided definition.
+#elif FMT_GCC_VERSION || FMT_CLANG_VERSION
+# define FMT_ALWAYS_INLINE inline __attribute__((always_inline))
+#else
+# define FMT_ALWAYS_INLINE inline
+#endif
+// A version of FMT_ALWAYS_INLINE to prevent code bloat in debug mode.
+#if defined(NDEBUG) || defined(FMT_GCC_OPTIMIZED)
+# define FMT_INLINE FMT_ALWAYS_INLINE
+#else
+# define FMT_INLINE inline
+#endif
+
+#ifndef FMT_BEGIN_NAMESPACE
+# define FMT_BEGIN_NAMESPACE \
+ namespace fmt { \
+ inline namespace v12 {
+# define FMT_END_NAMESPACE \
+ } \
+ }
+#endif
+
+#ifndef FMT_EXPORT
+# define FMT_EXPORT
+# define FMT_BEGIN_EXPORT
+# define FMT_END_EXPORT
+#endif
+
+#ifdef _WIN32
+# define FMT_WIN32 1
+#else
+# define FMT_WIN32 0
+#endif
+
+#if !defined(FMT_HEADER_ONLY) && FMT_WIN32
+# if defined(FMT_LIB_EXPORT)
+# define FMT_API __declspec(dllexport)
+# elif defined(FMT_SHARED)
+# define FMT_API __declspec(dllimport)
+# endif
+#elif defined(FMT_LIB_EXPORT) || defined(FMT_SHARED)
+# define FMT_API FMT_VISIBILITY("default")
+#endif
+#ifndef FMT_API
+# define FMT_API
+#endif
+
+#ifndef FMT_OPTIMIZE_SIZE
+# define FMT_OPTIMIZE_SIZE 0
+#endif
+
+// FMT_BUILTIN_TYPE=0 may result in smaller library size at the cost of higher
+// per-call binary size by passing built-in types through the extension API.
+#ifndef FMT_BUILTIN_TYPES
+# define FMT_BUILTIN_TYPES 1
+#endif
+
+#define FMT_APPLY_VARIADIC(expr) \
+ using unused = int[]; \
+ (void)unused { 0, (expr, 0)... }
+
+FMT_BEGIN_NAMESPACE
+
+// Implementations of enable_if_t and other metafunctions for older systems.
+template
+using enable_if_t = typename std::enable_if::type;
+template
+using conditional_t = typename std::conditional::type;
+template using bool_constant = std::integral_constant;
+template
+using remove_reference_t = typename std::remove_reference::type;
+template
+using remove_const_t = typename std::remove_const::type;
+template
+using remove_cvref_t = typename std::remove_cv>::type;
+template
+using make_unsigned_t = typename std::make_unsigned::type;
+template
+using underlying_t = typename std::underlying_type::type;
+template using decay_t = typename std::decay::type;
+using nullptr_t = decltype(nullptr);
+
+#if (FMT_GCC_VERSION && FMT_GCC_VERSION < 500) || FMT_MSC_VERSION
+// A workaround for gcc 4.9 & MSVC v141 to make void_t work in a SFINAE context.
+template struct void_t_impl {
+ using type = void;
+};
+template using void_t = typename void_t_impl::type;
+#else
+template using void_t = void;
+#endif
+
+struct monostate {
+ constexpr monostate() {}
+};
+
+// An enable_if helper to be used in template parameters which results in much
+// shorter symbols: https://godbolt.org/z/sWw4vP. Extra parentheses are needed
+// to workaround a bug in MSVC 2019 (see #1140 and #1186).
+#ifdef FMT_DOC
+# define FMT_ENABLE_IF(...)
+#else
+# define FMT_ENABLE_IF(...) fmt::enable_if_t<(__VA_ARGS__), int> = 0
+#endif
+
+template constexpr auto min_of(T a, T b) -> T {
+ return a < b ? a : b;
+}
+template constexpr auto max_of(T a, T b) -> T {
+ return a > b ? a : b;
+}
+
+FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
+ const char* message);
+
+namespace detail {
+// Suppresses "unused variable" warnings with the method described in
+// https://herbsutter.com/2009/10/18/mailbag-shutting-up-compiler-warnings/.
+// (void)var does not work on many Intel compilers.
+template FMT_CONSTEXPR void ignore_unused(const T&...) {}
+
+constexpr auto is_constant_evaluated(bool default_value = false) noexcept
+ -> bool {
+// Workaround for incompatibility between clang 14 and libstdc++ consteval-based
+// std::is_constant_evaluated: https://github.com/fmtlib/fmt/issues/3247.
+#if FMT_CPLUSPLUS >= 202002L && FMT_GLIBCXX_RELEASE >= 12 && \
+ (FMT_CLANG_VERSION >= 1400 && FMT_CLANG_VERSION < 1500)
+ ignore_unused(default_value);
+ return __builtin_is_constant_evaluated();
+#elif defined(__cpp_lib_is_constant_evaluated)
+ ignore_unused(default_value);
+ return std::is_constant_evaluated();
+#else
+ return default_value;
+#endif
+}
+
+// Suppresses "conditional expression is constant" warnings.
+template FMT_ALWAYS_INLINE constexpr auto const_check(T val) -> T {
+ return val;
+}
+
+FMT_NORETURN FMT_API void assert_fail(const char* file, int line,
+ const char* message);
+
+#if defined(FMT_ASSERT)
+// Use the provided definition.
+#elif defined(NDEBUG)
+// FMT_ASSERT is not empty to avoid -Wempty-body.
+# define FMT_ASSERT(condition, message) \
+ fmt::detail::ignore_unused((condition), (message))
+#else
+# define FMT_ASSERT(condition, message) \
+ ((condition) /* void() fails with -Winvalid-constexpr on clang 4.0.1 */ \
+ ? (void)0 \
+ : ::fmt::assert_fail(__FILE__, __LINE__, (message)))
+#endif
+
+#ifdef FMT_USE_INT128
+// Use the provided definition.
+#elif defined(__SIZEOF_INT128__) && !defined(__NVCC__) && \
+ !(FMT_CLANG_VERSION && FMT_MSC_VERSION)
+# define FMT_USE_INT128 1
+using int128_opt = __int128_t; // An optional native 128-bit integer.
+using uint128_opt = __uint128_t;
+inline auto map(int128_opt x) -> int128_opt { return x; }
+inline auto map(uint128_opt x) -> uint128_opt { return x; }
+#else
+# define FMT_USE_INT128 0
+#endif
+#if !FMT_USE_INT128
+enum class int128_opt {};
+enum class uint128_opt {};
+// Reduce template instantiations.
+inline auto map(int128_opt) -> monostate { return {}; }
+inline auto map(uint128_opt) -> monostate { return {}; }
+#endif
+
+#ifdef FMT_USE_BITINT
+// Use the provided definition.
+#elif FMT_CLANG_VERSION >= 1500 && !defined(__CUDACC__)
+# define FMT_USE_BITINT 1
+#else
+# define FMT_USE_BITINT 0
+#endif
+
+#if FMT_USE_BITINT
+FMT_PRAGMA_CLANG(diagnostic ignored "-Wbit-int-extension")
+template using bitint = _BitInt(N);
+template using ubitint = unsigned _BitInt(N);
+#else
+template struct bitint {};
+template struct ubitint {};
+#endif // FMT_USE_BITINT
+
+// Casts a nonnegative integer to unsigned.
+template
+FMT_CONSTEXPR auto to_unsigned(Int value) -> make_unsigned_t {
+ FMT_ASSERT(std::is_unsigned::value || value >= 0, "negative value");
+ return static_cast>(value);
+}
+
+template
+using unsigned_char = conditional_t;
+
+// A heuristic to detect std::string and std::[experimental::]string_view.
+// It is mainly used to avoid dependency on <[experimental/]string_view>.
+template
+struct is_std_string_like : std::false_type {};
+template
+struct is_std_string_like().find_first_of(
+ typename T::value_type(), 0))>>
+ : std::is_convertible().data()),
+ const typename T::value_type*> {};
+
+// Check if the literal encoding is UTF-8.
+enum { is_utf8_enabled = "\u00A7"[1] == '\xA7' };
+enum { use_utf8 = !FMT_WIN32 || is_utf8_enabled };
+
+#ifndef FMT_UNICODE
+# define FMT_UNICODE 1
+#endif
+
+static_assert(!FMT_UNICODE || use_utf8,
+ "Unicode support requires compiling with /utf-8");
+
+template constexpr auto narrow(T*) -> char* { return nullptr; }
+constexpr FMT_ALWAYS_INLINE auto narrow(const char* s) -> const char* {
+ return s;
+}
+
+template
+FMT_CONSTEXPR auto compare(const Char* s1, const Char* s2, size_t n) -> int {
+ if (!is_constant_evaluated() && sizeof(Char) == 1) return memcmp(s1, s2, n);
+ for (; n != 0; ++s1, ++s2, --n) {
+ if (*s1 < *s2) return -1;
+ if (*s1 > *s2) return 1;
+ }
+ return 0;
+}
+
+namespace adl {
+using namespace std;
+
+template
+auto invoke_back_inserter()
+ -> decltype(back_inserter(std::declval()));
+} // namespace adl
+
+template
+struct is_back_insert_iterator : std::false_type {};
+
+template
+struct is_back_insert_iterator<
+ It, bool_constant()),
+ It>::value>> : std::true_type {};
+
+// Extracts a reference to the container from *insert_iterator.
+template
+inline FMT_CONSTEXPR20 auto get_container(OutputIt it) ->
+ typename OutputIt::container_type& {
+ struct accessor : OutputIt {
+ FMT_CONSTEXPR20 accessor(OutputIt base) : OutputIt(base) {}
+ using OutputIt::container;
+ };
+ return *accessor(it).container;
+}
+} // namespace detail
+
+// Parsing-related public API and forward declarations.
+FMT_BEGIN_EXPORT
+
+/**
+ * An implementation of `std::basic_string_view` for pre-C++17. It provides a
+ * subset of the API. `fmt::basic_string_view` is used for format strings even
+ * if `std::basic_string_view` is available to prevent issues when a library is
+ * compiled with a different `-std` option than the client code (which is not
+ * recommended).
+ */
+template class basic_string_view {
+ private:
+ const Char* data_;
+ size_t size_;
+
+ public:
+ using value_type = Char;
+ using iterator = const Char*;
+
+ constexpr basic_string_view() noexcept : data_(nullptr), size_(0) {}
+
+ /// Constructs a string view object from a C string and a size.
+ constexpr basic_string_view(const Char* s, size_t count) noexcept
+ : data_(s), size_(count) {}
+
+ constexpr basic_string_view(nullptr_t) = delete;
+
+ /// Constructs a string view object from a C string.
+#if FMT_GCC_VERSION
+ FMT_ALWAYS_INLINE
+#endif
+ FMT_CONSTEXPR20 basic_string_view(const Char* s) : data_(s) {
+#if FMT_HAS_BUILTIN(__builtin_strlen) || FMT_GCC_VERSION || FMT_CLANG_VERSION
+ if (std::is_same::value && !detail::is_constant_evaluated()) {
+ size_ = __builtin_strlen(detail::narrow(s)); // strlen is not constexpr.
+ return;
+ }
+#endif
+ size_t len = 0;
+ while (*s++) ++len;
+ size_ = len;
+ }
+
+ /// Constructs a string view from a `std::basic_string` or a
+ /// `std::basic_string_view` object.
+ template ::value&& std::is_same<
+ typename S::value_type, Char>::value)>
+ FMT_CONSTEXPR basic_string_view(const S& s) noexcept
+ : data_(s.data()), size_(s.size()) {}
+
+ /// Returns a pointer to the string data.
+ constexpr auto data() const noexcept -> const Char* { return data_; }
+
+ /// Returns the string size.
+ constexpr auto size() const noexcept -> size_t { return size_; }
+
+ constexpr auto begin() const noexcept -> iterator { return data_; }
+ constexpr auto end() const noexcept -> iterator { return data_ + size_; }
+
+ constexpr auto operator[](size_t pos) const noexcept -> const Char& {
+ return data_[pos];
+ }
+
+ FMT_CONSTEXPR void remove_prefix(size_t n) noexcept {
+ data_ += n;
+ size_ -= n;
+ }
+
+ FMT_CONSTEXPR auto starts_with(basic_string_view sv) const noexcept
+ -> bool {
+ return size_ >= sv.size_ && detail::compare(data_, sv.data_, sv.size_) == 0;
+ }
+ FMT_CONSTEXPR auto starts_with(Char c) const noexcept -> bool {
+ return size_ >= 1 && *data_ == c;
+ }
+ FMT_CONSTEXPR auto starts_with(const Char* s) const -> bool {
+ return starts_with(basic_string_view(s));
+ }
+
+ FMT_CONSTEXPR auto compare(basic_string_view other) const -> int {
+ int result =
+ detail::compare(data_, other.data_, min_of(size_, other.size_));
+ if (result != 0) return result;
+ return size_ == other.size_ ? 0 : (size_ < other.size_ ? -1 : 1);
+ }
+
+ FMT_CONSTEXPR friend auto operator==(basic_string_view lhs,
+ basic_string_view rhs) -> bool {
+ return lhs.compare(rhs) == 0;
+ }
+ friend auto operator!=(basic_string_view lhs, basic_string_view rhs) -> bool {
+ return lhs.compare(rhs) != 0;
+ }
+ friend auto operator<(basic_string_view lhs, basic_string_view rhs) -> bool {
+ return lhs.compare(rhs) < 0;
+ }
+ friend auto operator<=(basic_string_view lhs, basic_string_view rhs) -> bool {
+ return lhs.compare(rhs) <= 0;
+ }
+ friend auto operator>(basic_string_view lhs, basic_string_view rhs) -> bool {
+ return lhs.compare(rhs) > 0;
+ }
+ friend auto operator>=(basic_string_view lhs, basic_string_view rhs) -> bool {
+ return lhs.compare(rhs) >= 0;
+ }
+};
+
+using string_view = basic_string_view;
+
+template class basic_appender;
+using appender = basic_appender;
+
+// Checks whether T is a container with contiguous storage.
+template struct is_contiguous : std::false_type {};
+
+class context;
+template class generic_context;
+template class parse_context;
+
+// Longer aliases for C++20 compatibility.
+template using basic_format_parse_context = parse_context;
+using format_parse_context = parse_context;
+template
+using basic_format_context =
+ conditional_t::value, context,
+ generic_context>;
+using format_context = context;
+
+template
+using buffered_context =
+ conditional_t::value, context,
+ generic_context, Char>>;
+
+template class basic_format_arg;
+template class basic_format_args;
+
+// A separate type would result in shorter symbols but break ABI compatibility
+// between clang and gcc on ARM (#1919).
+using format_args = basic_format_args;
+
+// A formatter for objects of type T.
+template
+struct formatter {
+ // A deleted default constructor indicates a disabled formatter.
+ formatter() = delete;
+};
+
+/// Reports a format error at compile time or, via a `format_error` exception,
+/// at runtime.
+// This function is intentionally not constexpr to give a compile-time error.
+FMT_NORETURN FMT_API void report_error(const char* message);
+
+enum class presentation_type : unsigned char {
+ // Common specifiers:
+ none = 0,
+ debug = 1, // '?'
+ string = 2, // 's' (string, bool)
+
+ // Integral, bool and character specifiers:
+ dec = 3, // 'd'
+ hex, // 'x' or 'X'
+ oct, // 'o'
+ bin, // 'b' or 'B'
+ chr, // 'c'
+
+ // String and pointer specifiers:
+ pointer = 3, // 'p'
+
+ // Floating-point specifiers:
+ exp = 1, // 'e' or 'E' (1 since there is no FP debug presentation)
+ fixed, // 'f' or 'F'
+ general, // 'g' or 'G'
+ hexfloat // 'a' or 'A'
+};
+
+enum class align { none, left, right, center, numeric };
+enum class sign { none, minus, plus, space };
+enum class arg_id_kind { none, index, name };
+
+// Basic format specifiers for built-in and string types.
+class basic_specs {
+ private:
+ // Data is arranged as follows:
+ //
+ // 0 1 2 3
+ // 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ // +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ // |type |align| w | p | s |u|#|L| f | unused |
+ // +-----+-----+---+---+---+-+-+-+-----+---------------------------+
+ //
+ // w - dynamic width info
+ // p - dynamic precision info
+ // s - sign
+ // u - uppercase (e.g. 'X' for 'x')
+ // # - alternate form ('#')
+ // L - localized
+ // f - fill size
+ //
+ // Bitfields are not used because of compiler bugs such as gcc bug 61414.
+ enum : unsigned {
+ type_mask = 0x00007,
+ align_mask = 0x00038,
+ width_mask = 0x000C0,
+ precision_mask = 0x00300,
+ sign_mask = 0x00C00,
+ uppercase_mask = 0x01000,
+ alternate_mask = 0x02000,
+ localized_mask = 0x04000,
+ fill_size_mask = 0x38000,
+
+ align_shift = 3,
+ width_shift = 6,
+ precision_shift = 8,
+ sign_shift = 10,
+ fill_size_shift = 15,
+
+ max_fill_size = 4
+ };
+
+ unsigned data_ = 1 << fill_size_shift;
+ static_assert(sizeof(basic_specs::data_) * CHAR_BIT >= 18, "");
+
+ // Character (code unit) type is erased to prevent template bloat.
+ char fill_data_[max_fill_size] = {' '};
+
+ FMT_CONSTEXPR void set_fill_size(size_t size) {
+ data_ = (data_ & ~fill_size_mask) |
+ (static_cast(size) << fill_size_shift);
+ }
+
+ public:
+ constexpr auto type() const -> presentation_type {
+ return static_cast(data_ & type_mask);
+ }
+ FMT_CONSTEXPR void set_type(presentation_type t) {
+ data_ = (data_ & ~type_mask) | static_cast(t);
+ }
+
+ constexpr auto align() const -> align {
+ return static_cast((data_ & align_mask) >> align_shift);
+ }
+ FMT_CONSTEXPR void set_align(fmt::align a) {
+ data_ = (data_ & ~align_mask) | (static_cast(a) << align_shift);
+ }
+
+ constexpr auto dynamic_width() const -> arg_id_kind {
+ return static_cast((data_ & width_mask) >> width_shift);
+ }
+ FMT_CONSTEXPR void set_dynamic_width(arg_id_kind w) {
+ data_ = (data_ & ~width_mask) | (static_cast(w) << width_shift);
+ }
+
+ FMT_CONSTEXPR auto dynamic_precision() const -> arg_id_kind {
+ return static_cast((data_ & precision_mask) >>
+ precision_shift);
+ }
+ FMT_CONSTEXPR void set_dynamic_precision(arg_id_kind p) {
+ data_ = (data_ & ~precision_mask) |
+ (static_cast(p) << precision_shift);
+ }
+
+ constexpr auto dynamic() const -> bool {
+ return (data_ & (width_mask | precision_mask)) != 0;
+ }
+
+ constexpr auto sign() const -> sign {
+ return static_cast((data_ & sign_mask) >> sign_shift);
+ }
+ FMT_CONSTEXPR void set_sign(fmt::sign s) {
+ data_ = (data_ & ~sign_mask) | (static_cast(s) << sign_shift);
+ }
+
+ constexpr auto upper() const -> bool { return (data_ & uppercase_mask) != 0; }
+ FMT_CONSTEXPR void set_upper() { data_ |= uppercase_mask; }
+
+ constexpr auto alt() const -> bool { return (data_ & alternate_mask) != 0; }
+ FMT_CONSTEXPR void set_alt() { data_ |= alternate_mask; }
+ FMT_CONSTEXPR void clear_alt() { data_ &= ~alternate_mask; }
+
+ constexpr auto localized() const -> bool {
+ return (data_ & localized_mask) != 0;
+ }
+ FMT_CONSTEXPR void set_localized() { data_ |= localized_mask; }
+
+ constexpr auto fill_size() const -> size_t {
+ return (data_ & fill_size_mask) >> fill_size_shift;
+ }
+
+ template ::value)>
+ constexpr auto fill() const -> const Char* {
+ return fill_data_;
+ }
+ template ::value)>
+ constexpr auto fill() const -> const Char* {
+ return nullptr;
+ }
+
+ template constexpr auto fill_unit() const -> Char {
+ using uchar = unsigned char;
+ return static_cast(static_cast(fill_data_[0]) |
+ (static_cast(fill_data_[1]) << 8) |
+ (static_cast(fill_data_[2]) << 16));
+ }
+
+ FMT_CONSTEXPR void set_fill(char c) {
+ fill_data_[0] = c;
+ set_fill_size(1);
+ }
+
+ template
+ FMT_CONSTEXPR void set_fill(basic_string_view s) {
+ auto size = s.size();
+ set_fill_size(size);
+ if (size == 1) {
+ unsigned uchar = static_cast>(s[0]);
+ fill_data_[0] = static_cast(uchar);
+ fill_data_[1] = static_cast(uchar >> 8);
+ fill_data_[2] = static_cast(uchar >> 16);
+ return;
+ }
+ FMT_ASSERT(size <= max_fill_size, "invalid fill");
+ for (size_t i = 0; i < size; ++i)
+ fill_data_[i & 3] = static_cast(s[i]);
+ }
+
+ FMT_CONSTEXPR void copy_fill_from(const basic_specs& specs) {
+ set_fill_size(specs.fill_size());
+ for (size_t i = 0; i < max_fill_size; ++i)
+ fill_data_[i] = specs.fill_data_[i];
+ }
+};
+
+// Format specifiers for built-in and string types.
+struct format_specs : basic_specs {
+ int width;
+ int precision;
+
+ constexpr format_specs() : width(0), precision(-1) {}
+};
+
+/**
+ * Parsing context consisting of a format string range being parsed and an
+ * argument counter for automatic indexing.
+ */
+template class parse_context {
+ private:
+ basic_string_view fmt_;
+ int next_arg_id_;
+
+ enum { use_constexpr_cast = !FMT_GCC_VERSION || FMT_GCC_VERSION >= 1200 };
+
+ FMT_CONSTEXPR void do_check_arg_id(int arg_id);
+
+ public:
+ using char_type = Char;
+ using iterator = const Char*;
+
+ constexpr explicit parse_context(basic_string_view fmt,
+ int next_arg_id = 0)
+ : fmt_(fmt), next_arg_id_(next_arg_id) {}
+
+ /// Returns an iterator to the beginning of the format string range being
+ /// parsed.
+ constexpr auto begin() const noexcept -> iterator { return fmt_.begin(); }
+
+ /// Returns an iterator past the end of the format string range being parsed.
+ constexpr auto end() const noexcept -> iterator { return fmt_.end(); }
+
+ /// Advances the begin iterator to `it`.
+ FMT_CONSTEXPR void advance_to(iterator it) {
+ fmt_.remove_prefix(detail::to_unsigned(it - begin()));
+ }
+
+ /// Reports an error if using the manual argument indexing; otherwise returns
+ /// the next argument index and switches to the automatic indexing.
+ FMT_CONSTEXPR auto next_arg_id() -> int {
+ if (next_arg_id_ < 0) {
+ report_error("cannot switch from manual to automatic argument indexing");
+ return 0;
+ }
+ int id = next_arg_id_++;
+ do_check_arg_id(id);
+ return id;
+ }
+
+ /// Reports an error if using the automatic argument indexing; otherwise
+ /// switches to the manual indexing.
+ FMT_CONSTEXPR void check_arg_id(int id) {
+ if (next_arg_id_ > 0) {
+ report_error("cannot switch from automatic to manual argument indexing");
+ return;
+ }
+ next_arg_id_ = -1;
+ do_check_arg_id(id);
+ }
+ FMT_CONSTEXPR void check_arg_id(basic_string_view) {
+ next_arg_id_ = -1;
+ }
+ FMT_CONSTEXPR void check_dynamic_spec(int arg_id);
+};
+
+#ifndef FMT_USE_LOCALE
+# define FMT_USE_LOCALE (FMT_OPTIMIZE_SIZE <= 1)
+#endif
+
+// A type-erased reference to std::locale to avoid the heavy include.
+class locale_ref {
+#if FMT_USE_LOCALE
+ private:
+ const void* locale_; // A type-erased pointer to std::locale.
+
+ public:
+ constexpr locale_ref() : locale_(nullptr) {}
+
+ template
+ locale_ref(const Locale& loc) : locale_(&loc) {
+ // Check if std::isalpha is found via ADL to reduce the chance of misuse.
+ isalpha('x', loc);
+ }
+
+ inline explicit operator bool() const noexcept { return locale_ != nullptr; }
+#endif // FMT_USE_LOCALE
+
+ public:
+ template auto get() const -> Locale;
+};
+
+FMT_END_EXPORT
+
+namespace detail {
+
+// Specifies if `T` is a code unit type.
+template struct is_code_unit : std::false_type {};
+template <> struct is_code_unit : std::true_type {};
+template <> struct is_code_unit : std::true_type {};
+template <> struct is_code_unit : std::true_type {};
+template <> struct is_code_unit : std::true_type {};
+#ifdef __cpp_char8_t
+template <> struct is_code_unit : bool_constant {};
+#endif
+
+// Constructs fmt::basic_string_view from types implicitly convertible
+// to it, deducing Char. Explicitly convertible types such as the ones returned
+// from FMT_STRING are intentionally excluded.
+template ::value)>
+constexpr auto to_string_view(const Char* s) -> basic_string_view {
+ return s;
+}
+template ::value)>
+constexpr auto to_string_view(const T& s)
+ -> basic_string_view {
+ return s;
+}
+template
+constexpr auto to_string_view(basic_string_view s)
+ -> basic_string_view {
+ return s;
+}
+
+template
+struct has_to_string_view : std::false_type {};
+// detail:: is intentional since to_string_view is not an extension point.
+template
+struct has_to_string_view<
+ T, void_t()))>>
+ : std::true_type {};
+
+/// String's character (code unit) type. detail:: is intentional to prevent ADL.
+template ()))>
+using char_t = typename V::value_type;
+
+enum class type {
+ none_type,
+ // Integer types should go first,
+ int_type,
+ uint_type,
+ long_long_type,
+ ulong_long_type,
+ int128_type,
+ uint128_type,
+ bool_type,
+ char_type,
+ last_integer_type = char_type,
+ // followed by floating-point types.
+ float_type,
+ double_type,
+ long_double_type,
+ last_numeric_type = long_double_type,
+ cstring_type,
+ string_type,
+ pointer_type,
+ custom_type
+};
+
+// Maps core type T to the corresponding type enum constant.
+template
+struct type_constant : std::integral_constant {};
+
+#define FMT_TYPE_CONSTANT(Type, constant) \
+ template \
+ struct type_constant \
+ : std::integral_constant {}
+
+FMT_TYPE_CONSTANT(int, int_type);
+FMT_TYPE_CONSTANT(unsigned, uint_type);
+FMT_TYPE_CONSTANT(long long, long_long_type);
+FMT_TYPE_CONSTANT(unsigned long long, ulong_long_type);
+FMT_TYPE_CONSTANT(int128_opt, int128_type);
+FMT_TYPE_CONSTANT(uint128_opt, uint128_type);
+FMT_TYPE_CONSTANT(bool, bool_type);
+FMT_TYPE_CONSTANT(Char, char_type);
+FMT_TYPE_CONSTANT(float, float_type);
+FMT_TYPE_CONSTANT(double, double_type);
+FMT_TYPE_CONSTANT(long double, long_double_type);
+FMT_TYPE_CONSTANT(const Char*, cstring_type);
+FMT_TYPE_CONSTANT(basic_string_view, string_type);
+FMT_TYPE_CONSTANT(const void*, pointer_type);
+
+constexpr auto is_integral_type(type t) -> bool {
+ return t > type::none_type && t <= type::last_integer_type;
+}
+constexpr auto is_arithmetic_type(type t) -> bool {
+ return t > type::none_type && t <= type::last_numeric_type;
+}
+
+constexpr auto set(type rhs) -> int { return 1 << static_cast(rhs); }
+constexpr auto in(type t, int set) -> bool {
+ return ((set >> static_cast(t)) & 1) != 0;
+}
+
+// Bitsets of types.
+enum {
+ sint_set =
+ set(type::int_type) | set(type::long_long_type) | set(type::int128_type),
+ uint_set = set(type::uint_type) | set(type::ulong_long_type) |
+ set(type::uint128_type),
+ bool_set = set(type::bool_type),
+ char_set = set(type::char_type),
+ float_set = set(type::float_type) | set(type::double_type) |
+ set(type::long_double_type),
+ string_set = set(type::string_type),
+ cstring_set = set(type::cstring_type),
+ pointer_set = set(type::pointer_type)
+};
+
+struct view {};
+
+template
+struct is_view : std::false_type {};
+template
+struct is_view> : std::is_base_of {};
+
+template struct named_arg;
+template struct is_named_arg : std::false_type {};
+template struct is_static_named_arg : std::false_type {};
+
+template
+struct is_named_arg> : std::true_type {};
+
+template struct named_arg : view {
+ const Char* name;
+ const T& value;
+
+ named_arg(const Char* n, const T& v) : name(n), value(v) {}
+ static_assert(!is_named_arg::value, "nested named arguments");
+};
+
+template constexpr auto count() -> int { return B ? 1 : 0; }
+template constexpr auto count() -> int {
+ return (B1 ? 1 : 0) + count();
+}
+
+template constexpr auto count_named_args() -> int {
+ return count::value...>();
+}
+template constexpr auto count_static_named_args() -> int {
+ return count::value...>();
+}
+
+template struct named_arg_info {
+ const Char* name;
+ int id;
+};
+
+// named_args is non-const to suppress a bogus -Wmaybe-uninitialized in gcc 13.
+template
+FMT_CONSTEXPR void check_for_duplicate(named_arg_info* named_args,
+ int named_arg_index,
+ basic_string_view arg_name) {
+ for (int i = 0; i < named_arg_index; ++i) {
+ if (named_args[i].name == arg_name) report_error("duplicate named arg");
+ }
+}
+
+template ::value)>
+void init_named_arg(named_arg_info*, int& arg_index, int&, const T&) {
+ ++arg_index;
+}
+template ::value)>
+void init_named_arg(named_arg_info* named_args, int& arg_index,
+ int& named_arg_index, const T& arg) {
+ check_for_duplicate(named_args, named_arg_index, arg.name);
+ named_args[named_arg_index++] = {arg.name, arg_index++};
+}
+
+template ::value)>
+FMT_CONSTEXPR void init_static_named_arg(named_arg_info*, int& arg_index,
+ int&) {
+ ++arg_index;
+}
+template ::value)>
+FMT_CONSTEXPR void init_static_named_arg(named_arg_info* named_args,
+ int& arg_index, int& named_arg_index) {
+ check_for_duplicate(named_args, named_arg_index, T::name);
+ named_args[named_arg_index++] = {T::name, arg_index++};
+}
+
+// To minimize the number of types we need to deal with, long is translated
+// either to int or to long long depending on its size.
+enum { long_short = sizeof(long) == sizeof(int) && FMT_BUILTIN_TYPES };
+using long_type = conditional_t;
+using ulong_type = conditional_t;
+
+template
+using format_as_result =
+ remove_cvref_t()))>;
+template
+using format_as_member_result =
+ remove_cvref_t::format_as(std::declval()))>;
+
+template
+struct use_format_as : std::false_type {};
+// format_as member is only used to avoid injection into the std namespace.
+template
+struct use_format_as_member : std::false_type {};
+
+// Only map owning types because mapping views can be unsafe.
+template
+struct use_format_as<
+ T, bool_constant>::value>>
+ : std::true_type {};
+template
+struct use_format_as_member<
+ T, bool_constant>::value>>
+ : std::true_type {};
+
+template >
+using use_formatter =
+ bool_constant<(std::is_class::value || std::is_enum::value ||
+ std::is_union::value || std::is_array::value) &&
+ !has_to_string_view::value && !is_named_arg::value &&
+ !use_format_as::value && !use_format_as_member::value>;
+
+template >
+auto has_formatter_impl(T* p, buffered_context