mirror of
https://github.com/fmtlib/fmt.git
synced 2024-12-24 12:14:26 +00:00
Move check_sign to anonymous namespace.
This commit is contained in:
parent
ab35af53c5
commit
3947a7a98c
29
format.cc
29
format.cc
@ -188,6 +188,20 @@ const Char *find_closing_brace(const Char *s, int num_open_braces = 1) {
|
||||
throw fmt::FormatError("unmatched '{' in format");
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
void check_sign(const Char *&s, const Arg &arg) {
|
||||
char sign = static_cast<char>(*s);
|
||||
if (arg.type > Arg::LAST_NUMERIC_TYPE) {
|
||||
throw fmt::FormatError(fmt::format(
|
||||
"format specifier '{}' requires numeric argument", sign));
|
||||
}
|
||||
if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
|
||||
throw fmt::FormatError(fmt::format(
|
||||
"format specifier '{}' requires signed argument", sign));
|
||||
}
|
||||
++s;
|
||||
}
|
||||
|
||||
// Checks if an argument is a valid printf width specifier and sets
|
||||
// left alignment if it is negative.
|
||||
class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
|
||||
@ -759,21 +773,6 @@ inline const Arg &fmt::BasicFormatter<Char>::parse_arg_index(const Char *&s) {
|
||||
return *arg;
|
||||
}
|
||||
|
||||
template <typename Char>
|
||||
void fmt::BasicFormatter<Char>::check_sign(
|
||||
const Char *&s, const Arg &arg) {
|
||||
char sign = static_cast<char>(*s);
|
||||
if (arg.type > Arg::LAST_NUMERIC_TYPE) {
|
||||
throw FormatError(fmt::format(
|
||||
"format specifier '{}' requires numeric argument", sign));
|
||||
}
|
||||
if (arg.type == Arg::UINT || arg.type == Arg::ULONG_LONG) {
|
||||
throw FormatError(fmt::format(
|
||||
"format specifier '{}' requires signed argument", sign));
|
||||
}
|
||||
++s;
|
||||
}
|
||||
|
||||
const Arg *fmt::internal::FormatterBase::next_arg(const char *&error) {
|
||||
if (next_arg_index_ < 0) {
|
||||
error = "cannot switch from manual to automatic argument indexing";
|
||||
|
Loading…
Reference in New Issue
Block a user