From a2a0d16167ffbb11ca83fdd2489b4ce21e4173fd Mon Sep 17 00:00:00 2001 From: "Philipp A. Hartmann" Date: Sun, 31 Aug 2014 11:08:33 +0200 Subject: [PATCH] unittest.h: simplify AssertException Some compilers warn about the missing initialisation of the std::exception base class of the AssertException helper. The simplest solution is to inherit from std::logic_error instead, which provides all of the required functionality already. --- test/unittest/unittest.h | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/unittest/unittest.h b/test/unittest/unittest.h index a476db7..6f5230a 100644 --- a/test/unittest/unittest.h +++ b/test/unittest/unittest.h @@ -89,15 +89,9 @@ inline FILE* TempFile(char *filename) { #pragma warning(disable : 4127) #endif -class AssertException : public std::exception { +class AssertException : public std::logic_error { public: - AssertException(const char* w) : what_(w) {} - AssertException(const AssertException& other) : what_(other.what_) {} - AssertException& operator=(const AssertException& rhs) { what_ = rhs.what_; return *this; } - virtual const char* what() const throw() { return what_; } - -private: - const char* what_; + AssertException(const char* w) : std::logic_error(w) {} }; #define RAPIDJSON_ASSERT(x) if (!(x)) throw AssertException(RAPIDJSON_STRINGIFY(x))