Remove USE_NOTHROW and make ConversionException inline

This commit is contained in:
Martchus 2018-03-11 22:39:01 +01:00
parent 62902f98e8
commit f40a800107
5 changed files with 35 additions and 45 deletions

View File

@ -33,7 +33,7 @@ Failure::Failure(const std::string &what)
/*! /*!
* Destroys the Failure. * Destroys the Failure.
*/ */
Failure::~Failure() USE_NOTHROW Failure::~Failure() noexcept
{ {
} }
@ -41,7 +41,7 @@ Failure::~Failure() USE_NOTHROW
* Returns a C-style character string describing the cause * Returns a C-style character string describing the cause
* of the Failure. * of the Failure.
*/ */
const char *Failure::what() const USE_NOTHROW const char *Failure::what() const noexcept
{ {
return m_what.c_str(); return m_what.c_str();
} }

View File

@ -13,9 +13,9 @@ class CPP_UTILITIES_EXPORT Failure : public std::exception {
public: public:
Failure(); Failure();
Failure(const std::string &what); Failure(const std::string &what);
~Failure() USE_NOTHROW; ~Failure() noexcept;
virtual const char *what() const USE_NOTHROW; virtual const char *what() const noexcept;
private: private:
std::string m_what; std::string m_what;

View File

@ -84,20 +84,6 @@
#define LIB_HIDDEN __attribute__((visibility("hidden"))) #define LIB_HIDDEN __attribute__((visibility("hidden")))
#endif #endif
/*!
* \def USE_NOTHROW
* \brief Marks a function as never throwing, under no circumstances.
* \remarks If the function does nevertheless throw, the behaviour is undefined.
*/
#ifndef USE_NOTHROW
#if __cplusplus >= 201103L
#define USE_NOTHROW noexcept
#else
#define USE_NOTHROW throw()
#endif
#endif
/*! /*!
* \def DECLARE_ENUM * \def DECLARE_ENUM
* \brief Declares an enum without preventing lupdate to parse the file correctly. * \brief Declares an enum without preventing lupdate to parse the file correctly.

View File

@ -2,31 +2,11 @@
namespace ConversionUtilities { namespace ConversionUtilities {
/*!
* \class ConversionUtilities::ConversionException
* \brief The ConversionException class is thrown by the various conversion
* functions of this library when a conversion error occurs.
*/
/*!
* \brief Constructs a new ConversionException.
*/
ConversionException::ConversionException() USE_NOTHROW : runtime_error("unable to convert")
{
}
/*!
* \brief Constructs a new ConversionException. \a what is a std::string
* describing the cause of the ConversionException.
*/
ConversionException::ConversionException(const std::string &what) USE_NOTHROW : runtime_error(what)
{
}
/*! /*!
* \brief Destroys the ConversionException. * \brief Destroys the ConversionException.
*/ */
ConversionException::~ConversionException() USE_NOTHROW ConversionException::~ConversionException()
{ {
} }
} // namespace ConversionUtilities } // namespace ConversionUtilities

View File

@ -10,17 +10,41 @@ namespace ConversionUtilities {
class CPP_UTILITIES_EXPORT ConversionException : public std::runtime_error { class CPP_UTILITIES_EXPORT ConversionException : public std::runtime_error {
public: public:
ConversionException() USE_NOTHROW; ConversionException() noexcept;
ConversionException(const std::string &what) USE_NOTHROW; ConversionException(const std::string &what) noexcept;
ConversionException(const char *what) USE_NOTHROW; ConversionException(const char *what) noexcept;
~ConversionException() USE_NOTHROW; ~ConversionException() override;
}; };
/*!
* \class ConversionUtilities::ConversionException
* \brief The ConversionException class is thrown by the various conversion
* functions of this library when a conversion error occurs.
*/
/*!
* \brief Constructs a new ConversionException.
*/
inline ConversionException::ConversionException() noexcept
: runtime_error("unable to convert")
{
}
/*!
* \brief Constructs a new ConversionException. \a what is a std::string
* describing the cause of the ConversionException.
*/
inline ConversionException::ConversionException(const std::string &what) noexcept
: runtime_error(what)
{
}
/*! /*!
* \brief Constructs a new ConversionException. \a what is a C-style string * \brief Constructs a new ConversionException. \a what is a C-style string
* describing the cause of the ConversionException. * describing the cause of the ConversionException.
*/ */
inline ConversionException::ConversionException(const char *what) USE_NOTHROW : std::runtime_error(what) inline ConversionException::ConversionException(const char *what) noexcept
: std::runtime_error(what)
{ {
} }