From ca0437556d5652d555afe05078552065036545df Mon Sep 17 00:00:00 2001 From: "Markus F.X.J. Oberhumer" Date: Tue, 8 Dec 2020 00:45:41 +0100 Subject: [PATCH] Start using "noexcept". --- src/except.cpp | 8 ++++---- src/except.h | 44 ++++++++++++++++++++++---------------------- src/stdcxx.h | 1 - 3 files changed, 26 insertions(+), 27 deletions(-) diff --git a/src/except.cpp b/src/except.cpp index 2d339a41..ca35f824 100644 --- a/src/except.cpp +++ b/src/except.cpp @@ -35,7 +35,7 @@ unsigned long Throwable::counter = 0; -Throwable::Throwable(const char *m, int e, bool w) NOTHROW +Throwable::Throwable(const char *m, int e, bool w) noexcept : super(), msg(NULL), err(e), is_warning(w) { if (m) @@ -47,7 +47,7 @@ Throwable::Throwable(const char *m, int e, bool w) NOTHROW } -Throwable::Throwable(const Throwable &other) NOTHROW +Throwable::Throwable(const Throwable &other) noexcept : super(other), msg(NULL), err(other.err), is_warning(other.is_warning) { if (other.msg) @@ -59,7 +59,7 @@ Throwable::Throwable(const Throwable &other) NOTHROW } -Throwable::~Throwable() NOTHROW +Throwable::~Throwable() noexcept { #if 0 counter--; @@ -187,7 +187,7 @@ void throwEOFException(const char *msg, int e) // **************************************************************************/ -const char *prettyName(const char *n) NOTHROW +const char *prettyName(const char *n) noexcept { if (n == NULL) return "(null)"; diff --git a/src/except.h b/src/except.h index aee9a63a..62e58325 100644 --- a/src/except.h +++ b/src/except.h @@ -31,7 +31,7 @@ #ifdef __cplusplus -const char *prettyName(const char *n) NOTHROW; +const char *prettyName(const char *n) noexcept; /************************************************************************* @@ -42,13 +42,13 @@ class Throwable : public std::exception { typedef std::exception super; protected: - Throwable(const char *m = 0, int e = 0, bool w = false) NOTHROW; + Throwable(const char *m = 0, int e = 0, bool w = false) noexcept; public: - Throwable(const Throwable &) NOTHROW; - virtual ~Throwable() NOTHROW; - const char *getMsg() const NOTHROW { return msg; } - int getErrno() const NOTHROW { return err; } - bool isWarning() const NOTHROW { return is_warning; } + Throwable(const Throwable &) noexcept; + virtual ~Throwable() noexcept; + const char *getMsg() const noexcept { return msg; } + int getErrno() const noexcept { return err; } + bool isWarning() const noexcept { return is_warning; } private: char *msg; int err; @@ -71,7 +71,7 @@ class Exception : public Throwable { typedef Throwable super; public: - Exception(const char *m = 0, int e = 0, bool w = false) NOTHROW : super(m,e,w) { } + Exception(const char *m = 0, int e = 0, bool w = false) noexcept : super(m,e,w) { } }; @@ -80,7 +80,7 @@ class Error : public Throwable { typedef Throwable super; public: - Error(const char *m = 0, int e = 0) NOTHROW : super(m,e) { } + Error(const char *m = 0, int e = 0) noexcept : super(m,e) { } }; @@ -92,7 +92,7 @@ class OutOfMemoryException : public Exception { typedef Exception super; public: - OutOfMemoryException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { } + OutOfMemoryException(const char *m = 0, int e = 0) noexcept : super(m,e) { } }; @@ -100,7 +100,7 @@ class IOException : public Exception { typedef Exception super; public: - IOException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { } + IOException(const char *m = 0, int e = 0) noexcept : super(m,e) { } }; @@ -108,7 +108,7 @@ class EOFException : public IOException { typedef IOException super; public: - EOFException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { } + EOFException(const char *m = 0, int e = 0) noexcept : super(m,e) { } }; @@ -116,7 +116,7 @@ class FileNotFoundException : public IOException { typedef IOException super; public: - FileNotFoundException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { } + FileNotFoundException(const char *m = 0, int e = 0) noexcept : super(m,e) { } }; @@ -124,7 +124,7 @@ class FileAlreadyExistsException : public IOException { typedef IOException super; public: - FileAlreadyExistsException(const char *m = 0, int e = 0) NOTHROW : super(m,e) { } + FileAlreadyExistsException(const char *m = 0, int e = 0) noexcept : super(m,e) { } }; @@ -136,35 +136,35 @@ class OverlayException : public Exception { typedef Exception super; public: - OverlayException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { } + OverlayException(const char *m = 0, bool w = false) noexcept : super(m,0,w) { } }; class CantPackException : public Exception { typedef Exception super; public: - CantPackException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { } + CantPackException(const char *m = 0, bool w = false) noexcept : super(m,0,w) { } }; class UnknownExecutableFormatException : public CantPackException { typedef CantPackException super; public: - UnknownExecutableFormatException(const char *m = 0, bool w = false) NOTHROW : super(m,w) { } + UnknownExecutableFormatException(const char *m = 0, bool w = false) noexcept : super(m,w) { } }; class AlreadyPackedException : public CantPackException { typedef CantPackException super; public: - AlreadyPackedException(const char *m = 0) NOTHROW : super(m) { is_warning = true; } + AlreadyPackedException(const char *m = 0) noexcept : super(m) { is_warning = true; } }; class NotCompressibleException : public CantPackException { typedef CantPackException super; public: - NotCompressibleException(const char *m = 0) NOTHROW : super(m) { } + NotCompressibleException(const char *m = 0) noexcept : super(m) { } }; @@ -172,14 +172,14 @@ class CantUnpackException : public Exception { typedef Exception super; public: - CantUnpackException(const char *m = 0, bool w = false) NOTHROW : super(m,0,w) { } + CantUnpackException(const char *m = 0, bool w = false) noexcept : super(m,0,w) { } }; class NotPackedException : public CantUnpackException { typedef CantUnpackException super; public: - NotPackedException(const char *m = 0) NOTHROW : super(m,true) { } + NotPackedException(const char *m = 0) noexcept : super(m,true) { } }; @@ -191,7 +191,7 @@ class InternalError : public Error { typedef Error super; public: - InternalError(const char *m = 0) NOTHROW : super(m,0) { } + InternalError(const char *m = 0) noexcept : super(m,0) { } }; diff --git a/src/stdcxx.h b/src/stdcxx.h index d6fd8559..c0ee33dc 100644 --- a/src/stdcxx.h +++ b/src/stdcxx.h @@ -30,7 +30,6 @@ #ifdef __cplusplus -#define NOTHROW ACC_CXX_NOTHROW #define DISABLE_NEW_DELETE ACC_CXX_DISABLE_NEW_DELETE /*************************************************************************