From 5adb9f7a394cc9097f8d1f9bd43d241e6373ace0 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Wed, 15 May 2013 08:59:44 -0700 Subject: [PATCH] Add support for noexcept --- format.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/format.h b/format.h index 549b219d..3c37fefe 100644 --- a/format.h +++ b/format.h @@ -41,6 +41,12 @@ #include #include +// Define FMT_USE_NOEXCEPT to make format use noexcept (C++11 feature). +#if FMT_USE_NOEXCEPT || \ + (defined(__has_feature) && __has_feature(cxx_noexcept)) +# define FMT_NOEXCEPT(expr) noexcept(expr) +#endif + namespace fmt { namespace internal { @@ -957,7 +963,7 @@ class BasicFormatter : public BasicWriter { custom.format = &internal::FormatCustomArg; } - ~Arg() { + ~Arg() FMT_NOEXCEPT(false) { // Format is called here to make sure that a referred object is // still alive, for example: // @@ -1204,7 +1210,7 @@ class TempFormatter : public internal::ArgInserter { /** Performs the actual formatting, invokes the action and destroys the object. */ - ~TempFormatter() { + ~TempFormatter() FMT_NOEXCEPT(false) { if (this->formatter()) action_(*this->Format()); }