fix: Support fmtlib 11.0.0

This commit is contained in:
Nebojsa Cvetkovic
2024-07-01 18:24:03 +01:00
parent a70031ab75
commit 0ac6a1701d
2 changed files with 6 additions and 2 deletions

View File

@@ -146,7 +146,11 @@ template<typename Int>
template<class Handler, typename FormatArg>
[[nodiscard]] constexpr int get_dynamic_spec(FormatArg arg)
{
#if defined MP_UNITS_USE_FMTLIB && FMT_VERSION >= 110000
const unsigned long long value = arg.visit(Handler{});
#else
const unsigned long long value = MP_UNITS_STD_FMT::visit_format_arg(Handler{}, arg);
#endif
if (value > ::mp_units::detail::to_unsigned(std::numeric_limits<int>::max())) {
MP_UNITS_THROW(MP_UNITS_STD_FMT::format_error("number is too big"));
}

View File

@@ -467,8 +467,8 @@ public:
return parse_defaults_specs(it, end);
}
template<typename OutIt>
OutIt format(const quantity_t& q, MP_UNITS_STD_FMT::basic_format_context<OutIt, Char>& ctx) const
template<typename FormatContext>
auto format(const quantity_t& q, FormatContext& ctx) const
{
auto specs = specs_;
mp_units::detail::handle_dynamic_spec<mp_units::detail::width_checker>(specs.width, specs.width_ref, ctx);