Add ArgVisitor::report_unhandled_arg

and get rid of FMT_RETURN_AFTER_THROW.
This commit is contained in:
vitaut 2015-03-26 08:55:20 -07:00
parent d618f8baac
commit d4ea2d7fcb
2 changed files with 8 additions and 7 deletions

View File

@ -66,10 +66,8 @@ using fmt::internal::Arg;
#ifndef FMT_THROW #ifndef FMT_THROW
# if FMT_EXCEPTIONS # if FMT_EXCEPTIONS
# define FMT_THROW(x) throw x # define FMT_THROW(x) throw x
# define FMT_RETURN_AFTER_THROW(x)
# else # else
# define FMT_THROW(x) assert(false) # define FMT_THROW(x) assert(false)
# define FMT_RETURN_AFTER_THROW(x) return x
# endif # endif
#endif #endif
@ -291,9 +289,8 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
public: public:
explicit WidthHandler(fmt::FormatSpec &spec) : spec_(spec) {} explicit WidthHandler(fmt::FormatSpec &spec) : spec_(spec) {}
unsigned visit_unhandled_arg() { void report_unhandled_arg() {
FMT_THROW(fmt::FormatError("width is not integer")); FMT_THROW(fmt::FormatError("width is not integer"));
FMT_RETURN_AFTER_THROW(0);
} }
template <typename T> template <typename T>
@ -313,9 +310,8 @@ class WidthHandler : public fmt::internal::ArgVisitor<WidthHandler, unsigned> {
class PrecisionHandler : class PrecisionHandler :
public fmt::internal::ArgVisitor<PrecisionHandler, int> { public fmt::internal::ArgVisitor<PrecisionHandler, int> {
public: public:
unsigned visit_unhandled_arg() { void report_unhandled_arg() {
FMT_THROW(fmt::FormatError("precision is not integer")); FMT_THROW(fmt::FormatError("precision is not integer"));
FMT_RETURN_AFTER_THROW(0);
} }
template <typename T> template <typename T>

View File

@ -962,7 +962,12 @@ class MakeArg : public Arg {
template <typename Impl, typename Result> template <typename Impl, typename Result>
class ArgVisitor { class ArgVisitor {
public: 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) { Result visit_int(int value) {
return FMT_DISPATCH(visit_any_int(value)); return FMT_DISPATCH(visit_any_int(value));