mirror of
https://github.com/fmtlib/fmt.git
synced 2024-10-02 13:02:03 +00:00
Add ArgVisitor::report_unhandled_arg
and get rid of FMT_RETURN_AFTER_THROW.
This commit is contained in:
parent
d618f8baac
commit
d4ea2d7fcb
@ -66,10 +66,8 @@ using fmt::internal::Arg;
|
||||
#ifndef FMT_THROW
|
||||
# if FMT_EXCEPTIONS
|
||||
# define FMT_THROW(x) throw x
|
||||
# define FMT_RETURN_AFTER_THROW(x)
|
||||
# else
|
||||
# define FMT_THROW(x) assert(false)
|
||||
# define FMT_RETURN_AFTER_THROW(x) return x
|
||||
# endif
|
||||
#endif
|
||||
|
||||
@ -291,9 +289,8 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
|
||||
public:
|
||||
explicit WidthHandler(fmt::FormatSpec &spec) : spec_(spec) {}
|
||||
|
||||
unsigned visit_unhandled_arg() {
|
||||
void report_unhandled_arg() {
|
||||
FMT_THROW(fmt::FormatError("width is not integer"));
|
||||
FMT_RETURN_AFTER_THROW(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
@ -313,9 +310,8 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
|
||||
class PrecisionHandler :
|
||||
public fmt::internal::ArgVisitor<PrecisionHandler, int> {
|
||||
public:
|
||||
unsigned visit_unhandled_arg() {
|
||||
void report_unhandled_arg() {
|
||||
FMT_THROW(fmt::FormatError("precision is not integer"));
|
||||
FMT_RETURN_AFTER_THROW(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
7
format.h
7
format.h
@ -962,7 +962,12 @@ class MakeArg : public Arg {
|
||||
template <typename Impl, typename Result>
|
||||
class ArgVisitor {
|
||||
public:
|
||||
Result visit_unhandled_arg() { return Result(); }
|
||||
void report_unhandled_arg() {}
|
||||
|
||||
Result visit_unhandled_arg() {
|
||||
FMT_DISPATCH(report_unhandled_arg());
|
||||
return Result();
|
||||
}
|
||||
|
||||
Result visit_int(int value) {
|
||||
return FMT_DISPATCH(visit_any_int(value));
|
||||
|
Loading…
Reference in New Issue
Block a user