Use throw() when noexcept is not supported

This commit is contained in:
Carter Li
2015-02-14 09:58:29 +08:00
parent 950e6b9753
commit e2583ab5f3
7 changed files with 46 additions and 39 deletions

View File

@@ -114,9 +114,9 @@
// Define FMT_USE_NOEXCEPT to make C++ Format use noexcept (C++11 feature).
#if FMT_USE_NOEXCEPT || FMT_HAS_FEATURE(cxx_noexcept) || \
(FMT_GCC_VERSION >= 408 && __cplusplus >= 201103)
# define FMT_NOEXCEPT(expr) noexcept(expr)
# define FMT_NOEXCEPT noexcept
#else
# define FMT_NOEXCEPT(expr)
# define FMT_NOEXCEPT throw()
#endif
// A macro to disallow the copy constructor and operator= functions
@@ -290,7 +290,7 @@ class Buffer {
grow(capacity);
}
void clear() FMT_NOEXCEPT(true) { size_ = 0; }
void clear() FMT_NOEXCEPT { size_ = 0; }
void push_back(const T &value) {
if (size_ == capacity_)
@@ -623,11 +623,11 @@ class UTF16ToUTF8 {
#endif
void format_system_error(fmt::Writer &out, int error_code,
fmt::StringRef message) FMT_NOEXCEPT(true);
fmt::StringRef message) FMT_NOEXCEPT;
#ifdef _WIN32
void format_windows_error(fmt::Writer &out, int error_code,
fmt::StringRef message) FMT_NOEXCEPT(true);
fmt::StringRef message) FMT_NOEXCEPT;
#endif
// Computes max(Arg, 1) at compile time. It is used to avoid errors about
@@ -1561,7 +1561,7 @@ class BasicWriter {
Returns a pointer to the output buffer content. No terminating null
character is appended.
*/
const Char *data() const FMT_NOEXCEPT(true) { return &buffer_[0]; }
const Char *data() const FMT_NOEXCEPT { return &buffer_[0]; }
/**
Returns a pointer to the output buffer content with terminating null
@@ -1685,7 +1685,7 @@ class BasicWriter {
return *this;
}
void clear() FMT_NOEXCEPT(true) { buffer_.clear(); }
void clear() FMT_NOEXCEPT { buffer_.clear(); }
};
template <typename Char>
@@ -2102,7 +2102,7 @@ void format(BasicFormatter<Char> &f, const Char *&format_str, const T &value) {
// Reports a system error without throwing an exception.
// Can be used to report errors from destructors.
void report_system_error(int error_code, StringRef message) FMT_NOEXCEPT(true);
void report_system_error(int error_code, StringRef message) FMT_NOEXCEPT;
#ifdef _WIN32
@@ -2146,7 +2146,7 @@ class WindowsError : public SystemError {
// Reports a Windows error without throwing an exception.
// Can be used to report errors from destructors.
void report_windows_error(int error_code, StringRef message) FMT_NOEXCEPT(true);
void report_windows_error(int error_code, StringRef message) FMT_NOEXCEPT;
#endif