From d4ea2d7fcb483c7b5cf8db3caf1ca453ce215e23 Mon Sep 17 00:00:00 2001 From: vitaut Date: Thu, 26 Mar 2015 08:55:20 -0700 Subject: [PATCH] Add ArgVisitor::report_unhandled_arg and get rid of FMT_RETURN_AFTER_THROW. --- format.cc | 8 ++------ format.h | 7 ++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/format.cc b/format.cc index 6f02a81d..fe4f1b18 100644 --- a/format.cc +++ b/format.cc @@ -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 { 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 @@ -313,9 +310,8 @@ class WidthHandler : public fmt::internal::ArgVisitor { class PrecisionHandler : public fmt::internal::ArgVisitor { public: - unsigned visit_unhandled_arg() { + void report_unhandled_arg() { FMT_THROW(fmt::FormatError("precision is not integer")); - FMT_RETURN_AFTER_THROW(0); } template diff --git a/format.h b/format.h index ca3e5e96..a9ee73d5 100644 --- a/format.h +++ b/format.h @@ -962,7 +962,12 @@ class MakeArg : public Arg { template 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));