From 67b633880b764ac0ad108db778c7b829a3ae6fab Mon Sep 17 00:00:00 2001 From: Jens Breitbart Date: Sat, 20 Dec 2014 15:06:36 +0100 Subject: [PATCH 1/2] Replaced throw() with noexcept and removed some unneeded ';'. --- include/spdlog/common.h | 4 ++-- include/spdlog/details/file_helper.h | 2 +- include/spdlog/sinks/base_sink.h | 2 +- include/spdlog/sinks/syslog_sink.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 8208b832..daf51ceb 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -71,8 +71,8 @@ inline const char* to_str(spdlog::level::level_enum l) class spdlog_ex : public std::exception { public: - spdlog_ex(const std::string& msg) :_msg(msg) {}; - const char* what() const throw() override + spdlog_ex(const std::string& msg) :_msg(msg) {} + const char* what() const noexcept override { return _msg.c_str(); } diff --git a/include/spdlog/details/file_helper.h b/include/spdlog/details/file_helper.h index 9a045bd6..fbc48e70 100644 --- a/include/spdlog/details/file_helper.h +++ b/include/spdlog/details/file_helper.h @@ -51,7 +51,7 @@ public: explicit file_helper(bool auto_flush): _fd(nullptr), _auto_flush(auto_flush) - {}; + {} file_helper(const file_helper&) = delete; file_helper& operator=(const file_helper&) = delete; diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index a1384819..f1647ae0 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -56,7 +56,7 @@ public: { std::lock_guard lock(_mutex); _sink_it(msg); - }; + } protected: diff --git a/include/spdlog/sinks/syslog_sink.h b/include/spdlog/sinks/syslog_sink.h index b6bb5eca..0b8b36ba 100644 --- a/include/spdlog/sinks/syslog_sink.h +++ b/include/spdlog/sinks/syslog_sink.h @@ -75,7 +75,7 @@ public: void log(const details::log_msg &msg) override { ::syslog(syslog_prio_from_level(msg), "%s", msg.formatted.str().c_str()); - }; + } From 1e7814295bfa7fae994d706ecfcd1c35895a35a7 Mon Sep 17 00:00:00 2001 From: gabi Date: Sat, 20 Dec 2014 16:24:16 +0200 Subject: [PATCH 2/2] fixed noexcept in visual studio --- include/spdlog/common.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/include/spdlog/common.h b/include/spdlog/common.h index daf51ceb..d10a1d3b 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -27,12 +27,21 @@ #include #include +//visual studio does not support noexcept yet +#ifndef _MSC_VER +#define SPDLOG_NOEXCEPT noexcept +#else +#define SPDLOG_NOEXCEPT +#endif + namespace spdlog { class formatter; -namespace sinks { class sink;} +namespace sinks { +class sink; +} // Common types across the lib using log_clock = std::chrono::system_clock; @@ -72,7 +81,7 @@ class spdlog_ex : public std::exception { public: spdlog_ex(const std::string& msg) :_msg(msg) {} - const char* what() const noexcept override + const char* what() const SPDLOG_NOEXCEPT override { return _msg.c_str(); }