Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[upstream_utils] Upgrade to fmt 11.0.1 #6804

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion upstream_utils/update_fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


def main():
upstream_root = clone_repo("https://github.com/fmtlib/fmt", "11.0.0")
upstream_root = clone_repo("https://github.com/fmtlib/fmt", "11.0.1")
wpilib_root = get_repo_root()
wpiutil = os.path.join(wpilib_root, "wpiutil")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif

// The fmt library version in the form major * 10000 + minor * 100 + patch.
#define FMT_VERSION 110000
#define FMT_VERSION 110001

// Detect compiler versions.
#if defined(__clang__) && !defined(__ibmxl__)
Expand Down Expand Up @@ -262,7 +262,7 @@
#ifndef FMT_BEGIN_NAMESPACE
# define FMT_BEGIN_NAMESPACE \
namespace fmt { \
inline namespace v10 {
inline namespace v11 {
# define FMT_END_NAMESPACE \
} \
}
Expand Down Expand Up @@ -1760,7 +1760,7 @@ template <typename Context> class basic_format_arg {
* `vis(value)` will be called with the value of type `double`.
*/
template <typename Visitor>
FMT_CONSTEXPR auto visit(Visitor&& vis) -> decltype(vis(0)) {
FMT_CONSTEXPR auto visit(Visitor&& vis) const -> decltype(vis(0)) {
switch (type_) {
case detail::type::none_type:
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,8 +569,8 @@ using wprintf_args = basic_format_args<wprintf_context>;
/// arguments and can be implicitly converted to `printf_args`.
template <typename Char = char, typename... T>
inline auto make_printf_args(T&... args)
-> decltype(make_format_args<basic_printf_context<Char>>(args...)) {
return make_format_args<basic_printf_context<Char>>(args...);
-> decltype(fmt::make_format_args<basic_printf_context<Char>>(args...)) {
return fmt::make_format_args<basic_printf_context<Char>>(args...);
}

template <typename Char> struct vprintf_args {
Expand Down
78 changes: 56 additions & 22 deletions wpiutil/src/main/native/thirdparty/fmtlib/include/fmt/std.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ struct formatter<std::expected<T, E>, Char,

if (value.has_value()) {
out = detail::write<Char>(out, "expected(");
out = detail::write_escaped_alternative<Char>(out, value.value());
out = detail::write_escaped_alternative<Char>(out, *value);
} else {
out = detail::write<Char>(out, "unexpected(");
out = detail::write_escaped_alternative<Char>(out, value.error());
Expand Down Expand Up @@ -631,33 +631,67 @@ struct formatter<std::atomic_flag, Char> : formatter<bool, Char> {
#endif // __cpp_lib_atomic_flag_test

FMT_EXPORT
template <typename F, typename Char>
struct formatter<std::complex<F>, Char> : nested_formatter<F, Char> {
template <typename T, typename Char> struct formatter<std::complex<T>, Char> {
private:
// Functor because C++11 doesn't support generic lambdas.
struct writer {
const formatter<std::complex<F>, Char>* f;
const std::complex<F>& c;

template <typename OutputIt>
FMT_CONSTEXPR auto operator()(OutputIt out) -> OutputIt {
if (c.real() != 0) {
auto format_full = detail::string_literal<Char, '(', '{', '}', '+', '{',
'}', 'i', ')'>{};
return fmt::format_to(out, basic_string_view<Char>(format_full),
f->nested(c.real()), f->nested(c.imag()));
}
auto format_imag = detail::string_literal<Char, '{', '}', 'i'>{};
return fmt::format_to(out, basic_string_view<Char>(format_imag),
f->nested(c.imag()));
detail::dynamic_format_specs<Char> specs_;

template <typename FormatContext, typename OutputIt>
FMT_CONSTEXPR auto do_format(const std::complex<T>& c,
detail::dynamic_format_specs<Char>& specs,
FormatContext& ctx, OutputIt out) const
-> OutputIt {
if (c.real() != 0) {
*out++ = Char('(');
out = detail::write<Char>(out, c.real(), specs, ctx.locale());
specs.sign = sign::plus;
out = detail::write<Char>(out, c.imag(), specs, ctx.locale());
if (!detail::isfinite(c.imag())) *out++ = Char(' ');
*out++ = Char('i');
*out++ = Char(')');
return out;
}
};
out = detail::write<Char>(out, c.imag(), specs, ctx.locale());
if (!detail::isfinite(c.imag())) *out++ = Char(' ');
*out++ = Char('i');
return out;
}

public:
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
-> decltype(ctx.begin()) {
if (ctx.begin() == ctx.end() || *ctx.begin() == '}') return ctx.begin();
return parse_format_specs(ctx.begin(), ctx.end(), specs_, ctx,
detail::type_constant<T, Char>::value);
}

template <typename FormatContext>
auto format(const std::complex<F>& c, FormatContext& ctx) const
auto format(const std::complex<T>& c, FormatContext& ctx) const
-> decltype(ctx.out()) {
return this->write_padded(ctx, writer{this, c});
auto specs = specs_;
if (specs.width_ref.kind != detail::arg_id_kind::none ||
specs.precision_ref.kind != detail::arg_id_kind::none) {
detail::handle_dynamic_spec<detail::width_checker>(specs.width,
specs.width_ref, ctx);
detail::handle_dynamic_spec<detail::precision_checker>(
specs.precision, specs.precision_ref, ctx);
}

if (specs.width == 0) return do_format(c, specs, ctx, ctx.out());
auto buf = basic_memory_buffer<Char>();

auto outer_specs = format_specs();
outer_specs.width = specs.width;
outer_specs.fill = specs.fill;
outer_specs.align = specs.align;

specs.width = 0;
specs.fill = {};
specs.align = align::none;

do_format(c, specs, ctx, basic_appender<Char>(buf));
return detail::write<Char>(ctx.out(),
basic_string_view<Char>(buf.data(), buf.size()),
outer_specs);
}
};

Expand Down
Loading