Skip to content

Commit

Permalink
Updated fmt: 10.2.1 -> 11.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
mikekazakov committed Dec 17, 2024
1 parent ba5f55f commit e34dd47
Show file tree
Hide file tree
Showing 23 changed files with 5,443 additions and 4,737 deletions.
2 changes: 1 addition & 1 deletion 3rd_Party/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Verify the Xcode version with `xcode-select -p`.
| bz2 | 1.0.8 | 2019.07.13 | https://sourceware.org/git/bzip2.git
| Catch2 | 2.13.3 | 2020.10.31 | https://github.com/catchorg/Catch2
| curl | 8.7.1 | 2024.03.27 | https://github.com/curl/curl.git
| fmt | 10.2.1 | 2024.01.04 | https://github.com/fmtlib/fmt.git
| fmt | 11.0.2 | 2024.07.20 | https://github.com/fmtlib/fmt.git
| frozen | 1.2.0 | 2024.06.02 | https://github.com/serge-sans-paille/frozen
| gtest | 1.14.0 | 2023.08.02 | https://github.com/google/googletest.git
| letsmove | 1.25 | 2020.07.09 | https://github.com/potionfactory/LetsMove.git
Expand Down
3 changes: 2 additions & 1 deletion 3rd_Party/fmt/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ TMP_DIR=${CUR_DIR}/fmt.tmp
mkdir ${TMP_DIR}
cd ${TMP_DIR}

git clone -b 10.2.1 --single-branch --depth=1 https://github.com/fmtlib/fmt.git
git clone -b 11.0.2 --single-branch --depth=1 https://github.com/fmtlib/fmt.git

cd fmt
mkdir build
Expand All @@ -24,6 +24,7 @@ cmake \
-D BUILD_SHARED_LIBS="OFF" \
..
make -j
make test

cd ./../../..
rm -rf ./include/
Expand Down
115 changes: 54 additions & 61 deletions 3rd_Party/fmt/include/fmt/args.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
#ifndef FMT_ARGS_H_
#define FMT_ARGS_H_

#include <functional> // std::reference_wrapper
#include <memory> // std::unique_ptr
#include <vector>
#ifndef FMT_MODULE
# include <functional> // std::reference_wrapper
# include <memory> // std::unique_ptr
# include <vector>
#endif

#include "core.h"
#include "format.h" // std_string_view

FMT_BEGIN_NAMESPACE

Expand All @@ -28,15 +30,18 @@ auto unwrap(const std::reference_wrapper<T>& v) -> const T& {
return static_cast<const T&>(v);
}

class dynamic_arg_list {
// 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 storage_node_base is made a fake template.
template <typename = void> struct node {
virtual ~node() = default;
std::unique_ptr<node<>> next;
};
// 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 <typename = void> struct node {
virtual ~node() = default;
std::unique_ptr<node<>> next;
};

class dynamic_arg_list {
template <typename T> struct typed_node : node<> {
T value;

Expand All @@ -62,14 +67,10 @@ class dynamic_arg_list {
} // namespace detail

/**
\rst
A dynamic version of `fmt::format_arg_store`.
It's equipped with a storage to potentially temporary objects which lifetimes
could be shorter than the format arguments object.
It can be implicitly converted into `~fmt::basic_format_args` for passing
into type-erased formatting functions such as `~fmt::vformat`.
\endrst
* 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`.
*/
template <typename Context>
class dynamic_format_arg_store
Expand Down Expand Up @@ -147,22 +148,20 @@ class dynamic_format_arg_store
constexpr dynamic_format_arg_store() = default;

/**
\rst
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<fmt::format_context> store;
store.push_back(42);
store.push_back("abc");
store.push_back(1.5f);
std::string result = fmt::vformat("{} and {} and {}", store);
\endrst
*/
* 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<fmt::format_context> store;
* store.push_back(42);
* store.push_back("abc");
* store.push_back(1.5f);
* std::string result = fmt::vformat("{} and {} and {}", store);
*/
template <typename T> void push_back(const T& arg) {
if (detail::const_check(need_copy<T>::value))
emplace_arg(dynamic_args_.push<stored_type<T>>(arg));
Expand All @@ -171,20 +170,18 @@ class dynamic_format_arg_store
}

/**
\rst
Adds a reference to the argument into the dynamic store for later passing to
a formatting function.
**Example**::
fmt::dynamic_format_arg_store<fmt::format_context> 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"
\endrst
*/
* Adds a reference to the argument into the dynamic store for later passing
* to a formatting function.
*
* **Example**:
*
* fmt::dynamic_format_arg_store<fmt::format_context> 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 <typename T> void push_back(std::reference_wrapper<T> arg) {
static_assert(
need_copy<T>::value,
Expand All @@ -193,10 +190,10 @@ class dynamic_format_arg_store
}

/**
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.
*/
* 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 <typename T>
void push_back(const detail::named_arg<char_type, T>& arg) {
const char_type* arg_name =
Expand All @@ -209,19 +206,15 @@ class dynamic_format_arg_store
}
}

/** Erase all elements from the store */
/// Erase all elements from the store.
void clear() {
data_.clear();
named_info_.clear();
dynamic_args_ = detail::dynamic_arg_list();
}

/**
\rst
Reserves space to store at least *new_cap* arguments including
*new_cap_named* named arguments.
\endrst
*/
/// 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");
Expand Down
Loading

0 comments on commit e34dd47

Please sign in to comment.