Skip to content

Commit 13486f6

Browse files
committed
Remove get_dynamic_spec
1 parent 9bb14ff commit 13486f6

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

include/fmt/format.h

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3696,32 +3696,25 @@ struct dynamic_spec_getter {
36963696
}
36973697
};
36983698

3699-
template <typename Context, typename ID>
3700-
FMT_CONSTEXPR auto get_arg(Context& ctx, ID id) -> basic_format_arg<Context> {
3701-
auto arg = ctx.arg(id);
3702-
if (!arg) report_error("argument not found");
3703-
return arg;
3704-
}
3705-
37063699
template <typename Context>
3707-
FMT_CONSTEXPR auto get_dynamic_spec(
3708-
arg_id_kind kind, const arg_ref<typename Context::char_type>& ref,
3709-
Context& ctx) -> int {
3710-
FMT_ASSERT(kind != arg_id_kind::none, "");
3700+
FMT_CONSTEXPR void handle_dynamic_spec(
3701+
arg_id_kind kind, int& value,
3702+
const arg_ref<typename Context::char_type>& ref, Context& ctx) {
3703+
if (kind == arg_id_kind::none) return;
37113704
auto arg =
37123705
kind == arg_id_kind::index ? ctx.arg(ref.index) : ctx.arg(ref.name);
37133706
if (!arg) report_error("argument not found");
3714-
unsigned long long value = arg.visit(dynamic_spec_getter());
3715-
if (value > to_unsigned(max_value<int>()))
3707+
unsigned long long result = arg.visit(dynamic_spec_getter());
3708+
if (result > to_unsigned(max_value<int>()))
37163709
report_error("width/precision is out of range");
3717-
return static_cast<int>(value);
3710+
value = static_cast<int>(result);
37183711
}
37193712

37203713
template <typename Context>
3721-
FMT_CONSTEXPR void handle_dynamic_spec(
3722-
arg_id_kind kind, int& value,
3723-
const arg_ref<typename Context::char_type>& ref, Context& ctx) {
3724-
if (kind != arg_id_kind::none) value = get_dynamic_spec(kind, ref, ctx);
3714+
FMT_CONSTEXPR auto get_arg(Context& ctx, int id) -> basic_format_arg<Context> {
3715+
auto arg = ctx.arg(id);
3716+
if (!arg) report_error("argument not found");
3717+
return arg;
37253718
}
37263719

37273720
#if FMT_USE_NONTYPE_TEMPLATE_ARGS

0 commit comments

Comments
 (0)