From ced30375239851914224b9d84ec37ac3008a43ce Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Thu, 13 May 2021 19:01:21 -0700 Subject: [PATCH] Move dynamic specs to core.h --- include/fmt/core.h | 36 ++++++++++++++++++++++++++++++++++++ include/fmt/format.h | 36 ------------------------------------ 2 files changed, 36 insertions(+), 36 deletions(-) diff --git a/include/fmt/core.h b/include/fmt/core.h index 25b3427d..4353eb94 100644 --- a/include/fmt/core.h +++ b/include/fmt/core.h @@ -1870,6 +1870,42 @@ using format_specs = basic_format_specs; FMT_MODULE_EXPORT_END namespace detail { +enum class arg_id_kind { none, index, name }; + +// An argument reference. +template struct arg_ref { + FMT_CONSTEXPR arg_ref() : kind(arg_id_kind::none), val() {} + + FMT_CONSTEXPR explicit arg_ref(int index) + : kind(arg_id_kind::index), val(index) {} + FMT_CONSTEXPR explicit arg_ref(basic_string_view name) + : kind(arg_id_kind::name), val(name) {} + + FMT_CONSTEXPR arg_ref& operator=(int idx) { + kind = arg_id_kind::index; + val.index = idx; + return *this; + } + + arg_id_kind kind; + union value { + FMT_CONSTEXPR value(int id = 0) : index{id} {} + FMT_CONSTEXPR value(basic_string_view n) : name(n) {} + + int index; + basic_string_view name; + } val; +}; + +// Format specifiers with width and precision resolved at formatting rather +// than parsing time to allow re-using the same parsed specifiers with +// different sets of arguments (precompilation of format strings). +template +struct dynamic_format_specs : basic_format_specs { + arg_ref width_ref; + arg_ref precision_ref; +}; + template constexpr bool is_ascii_letter(Char c) { return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'); } diff --git a/include/fmt/format.h b/include/fmt/format.h index 5eea9f92..fc3f49f0 100644 --- a/include/fmt/format.h +++ b/include/fmt/format.h @@ -2507,42 +2507,6 @@ class specs_handler : public specs_setter { Context& context_; }; -enum class arg_id_kind { none, index, name }; - -// An argument reference. -template struct arg_ref { - FMT_CONSTEXPR arg_ref() : kind(arg_id_kind::none), val() {} - - FMT_CONSTEXPR explicit arg_ref(int index) - : kind(arg_id_kind::index), val(index) {} - FMT_CONSTEXPR explicit arg_ref(basic_string_view name) - : kind(arg_id_kind::name), val(name) {} - - FMT_CONSTEXPR arg_ref& operator=(int idx) { - kind = arg_id_kind::index; - val.index = idx; - return *this; - } - - arg_id_kind kind; - union value { - FMT_CONSTEXPR value(int id = 0) : index{id} {} - FMT_CONSTEXPR value(basic_string_view n) : name(n) {} - - int index; - basic_string_view name; - } val; -}; - -// Format specifiers with width and precision resolved at formatting rather -// than parsing time to allow re-using the same parsed specifiers with -// different sets of arguments (precompilation of format strings). -template -struct dynamic_format_specs : basic_format_specs { - arg_ref width_ref; - arg_ref precision_ref; -}; - // Format spec handler that saves references to arguments representing dynamic // width and precision to be resolved at formatting time. template