20 General utilities library [utilities]
namespace std {
template<class charT>
class basic_format_parse_context {
public:
using char_type = charT;
using const_iterator = typename basic_string_view<charT>::const_iterator;
using iterator = const_iterator;
private:
iterator begin_;
iterator end_;
enum indexing { unknown, manual, automatic };
indexing indexing_;
size_t next_arg_id_;
size_t num_args_;
public:
constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
size_t num_args = 0) noexcept;
basic_format_parse_context(const basic_format_parse_context&) = delete;
basic_format_parse_context& operator=(const basic_format_parse_context&) = delete;
constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr void advance_to(const_iterator it);
constexpr size_t next_arg_id();
constexpr void check_arg_id(size_t id);
};
}
An instance of
basic_format_parse_context holds
the format string parsing state consisting of
the format string range being parsed and
the argument counter for automatic indexing
. constexpr explicit basic_format_parse_context(basic_string_view<charT> fmt,
size_t num_args = 0) noexcept;
Effects: Initializes
begin_ with
fmt.begin(),
end_ with
fmt.end(),
indexing_ with
unknown,
next_arg_id_ with
0, and
num_args_ with
num_args. constexpr const_iterator begin() const noexcept;
constexpr const_iterator end() const noexcept;
constexpr void advance_to(const_iterator it);
Preconditions: end() is reachable from
it. Effects: Equivalent to: begin_ = it;
constexpr size_t next_arg_id();
Effects: If
indexing_ != manual, equivalent to:
if (indexing_ == unknown)
indexing_ = automatic;
return next_arg_id_++;
Throws: format_error if
indexing_ == manual
which indicates mixing of automatic and manual argument indexing
. constexpr void check_arg_id(size_t id);
Effects: If
indexing_ != automatic, equivalent to:
if (indexing_ == unknown)
indexing_ = manual;
Throws: format_error if
indexing_ == automatic which indicates mixing of automatic and
manual argument indexing
. Remarks: Call expressions where
id >= num_args_ are not
core constant expressions (
[expr.const])
.