move to c++14

pull/1884/head
gabime 5 years ago
parent d6dbdbf27a
commit ecda02878b

@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.2)
if(${CMAKE_VERSION} VERSION_LESS 3.11)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
else()
cmake_policy(VERSION 3.11)
cmake_policy(VERSION 3.14)
endif()
enable_language(C)

@ -13,17 +13,17 @@ static string_view_t level_string_views[] SPDLOG_LEVEL_NAMES;
static const char *short_level_names[] SPDLOG_SHORT_LEVEL_NAMES;
SPDLOG_INLINE string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
SPDLOG_INLINE string_view_t &to_string_view(spdlog::level::level_enum l) noexcept
{
return level_string_views[l];
}
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT
SPDLOG_INLINE const char *to_short_c_str(spdlog::level::level_enum l) noexcept
{
return short_level_names[l];
}
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT
SPDLOG_INLINE spdlog::level::level_enum from_str(const std::string &name) noexcept
{
int level = 0;
for (const auto &level_str : level_string_views)
@ -58,7 +58,7 @@ SPDLOG_INLINE spdlog_ex::spdlog_ex(const std::string &msg, int last_errno)
msg_ = fmt::to_string(outbuf);
}
SPDLOG_INLINE const char *spdlog_ex::what() const SPDLOG_NOEXCEPT
SPDLOG_INLINE const char *spdlog_ex::what() const noexcept
{
return msg_.c_str();
}

@ -35,15 +35,6 @@
#include <spdlog/fmt/fmt.h>
// visual studio upto 2013 does not support noexcept nor constexpr
#if defined(_MSC_VER) && (_MSC_VER < 1900)
#define SPDLOG_NOEXCEPT _NOEXCEPT
#define SPDLOG_CONSTEXPR
#else
#define SPDLOG_NOEXCEPT noexcept
#define SPDLOG_CONSTEXPR constexpr
#endif
#if defined(__GNUC__) || defined(__clang__)
#define SPDLOG_DEPRECATED __attribute__((deprecated))
#elif defined(_MSC_VER)
@ -163,9 +154,9 @@ enum level_enum
}
#endif
SPDLOG_API string_view_t &to_string_view(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) SPDLOG_NOEXCEPT;
SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) SPDLOG_NOEXCEPT;
SPDLOG_API string_view_t &to_string_view(spdlog::level::level_enum l) noexcept;
SPDLOG_API const char *to_short_c_str(spdlog::level::level_enum l) noexcept;
SPDLOG_API spdlog::level::level_enum from_str(const std::string &name) noexcept;
using level_hasher = std::hash<int>;
} // namespace level
@ -198,7 +189,7 @@ class SPDLOG_API spdlog_ex : public std::exception
public:
explicit spdlog_ex(std::string msg);
spdlog_ex(const std::string &msg, int last_errno);
const char *what() const SPDLOG_NOEXCEPT override;
const char *what() const noexcept override;
private:
std::string msg_;
@ -209,14 +200,14 @@ SPDLOG_API void throw_spdlog_ex(std::string msg);
struct source_loc
{
SPDLOG_CONSTEXPR source_loc() = default;
SPDLOG_CONSTEXPR source_loc(const char *filename_in, int line_in, const char *funcname_in)
constexpr source_loc() = default;
constexpr source_loc(const char *filename_in, int line_in, const char *funcname_in)
: filename{filename_in}
, line{line_in}
, funcname{funcname_in}
{}
SPDLOG_CONSTEXPR bool empty() const SPDLOG_NOEXCEPT
constexpr bool empty() const noexcept
{
return line == 0;
}
@ -230,7 +221,10 @@ namespace details {
#if __cplusplus >= 201402L // C++14 and beyond
using std::make_unique;
#define SPDLOG_VALIDATE_FMT(f) FMT_STRING(f)
#else
#define SPDLOG_VALIDATE_FMT(f) FMT_STRING(f)
template<typename T, typename... Args>
std::unique_ptr<T> make_unique(Args &&... args)
{

@ -15,7 +15,7 @@ SPDLOG_INLINE backtracer::backtracer(const backtracer &other)
messages_ = other.messages_;
}
SPDLOG_INLINE backtracer::backtracer(backtracer &&other) SPDLOG_NOEXCEPT
SPDLOG_INLINE backtracer::backtracer(backtracer &&other) noexcept
{
std::lock_guard<std::mutex> lock(other.mutex_);
enabled_ = other.enabled();

@ -25,7 +25,7 @@ public:
backtracer() = default;
backtracer(const backtracer &other);
backtracer(backtracer &&other) SPDLOG_NOEXCEPT;
backtracer(backtracer &&other) noexcept;
backtracer &operator=(backtracer other);
void enable(size_t size);

@ -34,12 +34,12 @@ public:
// move cannot be default,
// since we need to reset head_, tail_, etc to zero in the moved object
circular_q(circular_q &&other) SPDLOG_NOEXCEPT
circular_q(circular_q &&other) noexcept
{
copy_moveable(std::move(other));
}
circular_q &operator=(circular_q &&other) SPDLOG_NOEXCEPT
circular_q &operator=(circular_q &&other) noexcept
{
copy_moveable(std::move(other));
return *this;
@ -123,7 +123,7 @@ public:
private:
// copy from other&& and reset it to disabled state
void copy_moveable(circular_q &&other) SPDLOG_NOEXCEPT
void copy_moveable(circular_q &&other) noexcept
{
max_items_ = other.max_items_;
head_ = other.head_;

@ -12,7 +12,7 @@ namespace spdlog {
namespace details {
namespace fmt_helper {
inline spdlog::string_view_t to_string_view(const memory_buf_t &buf) SPDLOG_NOEXCEPT
inline spdlog::string_view_t to_string_view(const memory_buf_t &buf) noexcept
{
return spdlog::string_view_t{buf.data(), buf.size()};
}

@ -26,7 +26,7 @@ SPDLOG_INLINE log_msg_buffer::log_msg_buffer(const log_msg_buffer &other)
update_string_views();
}
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT : log_msg{other}, buffer{std::move(other.buffer)}
SPDLOG_INLINE log_msg_buffer::log_msg_buffer(log_msg_buffer &&other) noexcept : log_msg{other}, buffer{std::move(other.buffer)}
{
update_string_views();
}
@ -40,7 +40,7 @@ SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(const log_msg_buffer &ot
return *this;
}
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT
SPDLOG_INLINE log_msg_buffer &log_msg_buffer::operator=(log_msg_buffer &&other) noexcept
{
log_msg::operator=(other);
buffer = std::move(other.buffer);

@ -20,9 +20,9 @@ public:
log_msg_buffer() = default;
explicit log_msg_buffer(const log_msg &orig_msg);
log_msg_buffer(const log_msg_buffer &other);
log_msg_buffer(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
log_msg_buffer(log_msg_buffer &&other) noexcept;
log_msg_buffer &operator=(const log_msg_buffer &other);
log_msg_buffer &operator=(log_msg_buffer &&other) SPDLOG_NOEXCEPT;
log_msg_buffer &operator=(log_msg_buffer &&other) noexcept;
};
} // namespace details

@ -68,7 +68,7 @@ namespace spdlog {
namespace details {
namespace os {
SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
SPDLOG_INLINE spdlog::log_clock::time_point now() noexcept
{
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
@ -81,7 +81,7 @@ SPDLOG_INLINE spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT
return log_clock::now();
#endif
}
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) noexcept
{
#ifdef _WIN32
@ -94,13 +94,13 @@ SPDLOG_INLINE std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
return tm;
}
SPDLOG_INLINE std::tm localtime() SPDLOG_NOEXCEPT
SPDLOG_INLINE std::tm localtime() noexcept
{
std::time_t now_t = ::time(nullptr);
return localtime(now_t);
}
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) noexcept
{
#ifdef _WIN32
@ -113,7 +113,7 @@ SPDLOG_INLINE std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT
return tm;
}
SPDLOG_INLINE std::tm gmtime() SPDLOG_NOEXCEPT
SPDLOG_INLINE std::tm gmtime() noexcept
{
std::time_t now_t = ::time(nullptr);
return gmtime(now_t);
@ -160,7 +160,7 @@ SPDLOG_INLINE bool fopen_s(FILE **fp, const filename_t &filename, const filename
return *fp == nullptr;
}
SPDLOG_INLINE int remove(const filename_t &filename) SPDLOG_NOEXCEPT
SPDLOG_INLINE int remove(const filename_t &filename) noexcept
{
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return ::_wremove(filename.c_str());
@ -169,12 +169,12 @@ SPDLOG_INLINE int remove(const filename_t &filename) SPDLOG_NOEXCEPT
#endif
}
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT
SPDLOG_INLINE int remove_if_exists(const filename_t &filename) noexcept
{
return path_exists(filename) ? remove(filename) : 0;
}
SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT
SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename2) noexcept
{
#if defined(_WIN32) && defined(SPDLOG_WCHAR_FILENAMES)
return ::_wrename(filename1.c_str(), filename2.c_str());
@ -184,7 +184,7 @@ SPDLOG_INLINE int rename(const filename_t &filename1, const filename_t &filename
}
// Return true if path exists (file or directory)
SPDLOG_INLINE bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT
SPDLOG_INLINE bool path_exists(const filename_t &filename) noexcept
{
#ifdef _WIN32
#ifdef SPDLOG_WCHAR_FILENAMES
@ -317,7 +317,7 @@ SPDLOG_INLINE int utc_minutes_offset(const std::tm &tm)
// Return current thread id as size_t
// It exists because the std::this_thread::get_id() is much slower(especially
// under VS 2013)
SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
SPDLOG_INLINE size_t _thread_id() noexcept
{
#ifdef _WIN32
return static_cast<size_t>(::GetCurrentThreadId());
@ -344,7 +344,7 @@ SPDLOG_INLINE size_t _thread_id() SPDLOG_NOEXCEPT
}
// Return current thread id as size_t (from thread local storage)
SPDLOG_INLINE size_t thread_id() SPDLOG_NOEXCEPT
SPDLOG_INLINE size_t thread_id() noexcept
{
#if defined(SPDLOG_NO_TLS)
return _thread_id();
@ -356,7 +356,7 @@ SPDLOG_INLINE size_t thread_id() SPDLOG_NOEXCEPT
// This is avoid msvc issue in sleep_for that happens if the clock changes.
// See https://github.com/gabime/spdlog/issues/609
SPDLOG_INLINE void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT
SPDLOG_INLINE void sleep_for_millis(int milliseconds) noexcept
{
#if defined(_WIN32)
::Sleep(milliseconds);
@ -380,7 +380,7 @@ SPDLOG_INLINE std::string filename_to_str(const filename_t &filename)
}
#endif
SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT
SPDLOG_INLINE int pid() noexcept
{
#ifdef _WIN32
@ -392,7 +392,7 @@ SPDLOG_INLINE int pid() SPDLOG_NOEXCEPT
// Determine if the terminal supports colors
// Based on: https://github.com/agauniyal/rang/
SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT
SPDLOG_INLINE bool is_color_terminal() noexcept
{
#ifdef _WIN32
return true;
@ -414,7 +414,7 @@ SPDLOG_INLINE bool is_color_terminal() SPDLOG_NOEXCEPT
// Determine if the terminal attached
// Source: https://github.com/agauniyal/rang/
SPDLOG_INLINE bool in_terminal(FILE *file) SPDLOG_NOEXCEPT
SPDLOG_INLINE bool in_terminal(FILE *file) noexcept
{
#ifdef _WIN32

@ -10,15 +10,15 @@ namespace spdlog {
namespace details {
namespace os {
SPDLOG_API spdlog::log_clock::time_point now() SPDLOG_NOEXCEPT;
SPDLOG_API spdlog::log_clock::time_point now() noexcept;
SPDLOG_API std::tm localtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
SPDLOG_API std::tm localtime(const std::time_t &time_tt) noexcept;
SPDLOG_API std::tm localtime() SPDLOG_NOEXCEPT;
SPDLOG_API std::tm localtime() noexcept;
SPDLOG_API std::tm gmtime(const std::time_t &time_tt) SPDLOG_NOEXCEPT;
SPDLOG_API std::tm gmtime(const std::time_t &time_tt) noexcept;
SPDLOG_API std::tm gmtime() SPDLOG_NOEXCEPT;
SPDLOG_API std::tm gmtime() noexcept;
// eol definition
#if !defined(SPDLOG_EOL)
@ -29,29 +29,29 @@ SPDLOG_API std::tm gmtime() SPDLOG_NOEXCEPT;
#endif
#endif
SPDLOG_CONSTEXPR static const char *default_eol = SPDLOG_EOL;
constexpr static const char *default_eol = SPDLOG_EOL;
// folder separator
#ifdef _WIN32
static const char folder_sep = '\\';
#else
SPDLOG_CONSTEXPR static const char folder_sep = '/';
constexpr static const char folder_sep = '/';
#endif
// fopen_s on non windows for writing
SPDLOG_API bool fopen_s(FILE **fp, const filename_t &filename, const filename_t &mode);
// Remove filename. return 0 on success
SPDLOG_API int remove(const filename_t &filename) SPDLOG_NOEXCEPT;
SPDLOG_API int remove(const filename_t &filename) noexcept;
// Remove file if exists. return 0 on success
// Note: Non atomic (might return failure to delete if concurrently deleted by other process/thread)
SPDLOG_API int remove_if_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
SPDLOG_API int remove_if_exists(const filename_t &filename) noexcept;
SPDLOG_API int rename(const filename_t &filename1, const filename_t &filename2) SPDLOG_NOEXCEPT;
SPDLOG_API int rename(const filename_t &filename1, const filename_t &filename2) noexcept;
// Return if file exists.
SPDLOG_API bool path_exists(const filename_t &filename) SPDLOG_NOEXCEPT;
SPDLOG_API bool path_exists(const filename_t &filename) noexcept;
// Return file size according to open FILE* object
SPDLOG_API size_t filesize(FILE *f);
@ -62,26 +62,26 @@ SPDLOG_API int utc_minutes_offset(const std::tm &tm = details::os::localtime());
// Return current thread id as size_t
// It exists because the std::this_thread::get_id() is much slower(especially
// under VS 2013)
SPDLOG_API size_t _thread_id() SPDLOG_NOEXCEPT;
SPDLOG_API size_t _thread_id() noexcept;
// Return current thread id as size_t (from thread local storage)
SPDLOG_API size_t thread_id() SPDLOG_NOEXCEPT;
SPDLOG_API size_t thread_id() noexcept;
// This is avoid msvc issue in sleep_for that happens if the clock changes.
// See https://github.com/gabime/spdlog/issues/609
SPDLOG_API void sleep_for_millis(int milliseconds) SPDLOG_NOEXCEPT;
SPDLOG_API void sleep_for_millis(int milliseconds) noexcept;
SPDLOG_API std::string filename_to_str(const filename_t &filename);
SPDLOG_API int pid() SPDLOG_NOEXCEPT;
SPDLOG_API int pid() noexcept;
// Determine if the terminal supports colors
// Source: https://github.com/agauniyal/rang/
SPDLOG_API bool is_color_terminal() SPDLOG_NOEXCEPT;
SPDLOG_API bool is_color_terminal() noexcept;
// Determine if the terminal attached
// Source: https://github.com/agauniyal/rang/
SPDLOG_API bool in_terminal(FILE *file) SPDLOG_NOEXCEPT;
SPDLOG_API bool in_terminal(FILE *file) noexcept;
#if (defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) || defined(SPDLOG_WCHAR_FILENAMES)) && defined(_WIN32)
SPDLOG_API void wstr_to_utf8buf(wstring_view_t wstr, memory_buf_t &target);

@ -126,8 +126,8 @@ struct formatter<spdlog::details::dump_info<T>>
template<typename FormatContext, typename Container>
auto format(const spdlog::details::dump_info<Container> &the_range, FormatContext &ctx) -> decltype(ctx.out())
{
SPDLOG_CONSTEXPR const char *hex_upper = "0123456789ABCDEF";
SPDLOG_CONSTEXPR const char *hex_lower = "0123456789abcdef";
constexpr const char *hex_upper = "0123456789ABCDEF";
constexpr const char *hex_lower = "0123456789abcdef";
const char *hex_chars = use_uppercase ? hex_upper : hex_lower;
#if FMT_VERSION < 60000

@ -25,7 +25,7 @@ SPDLOG_INLINE logger::logger(const logger &other)
, tracer_(other.tracer_)
{}
SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT : name_(std::move(other.name_)),
SPDLOG_INLINE logger::logger(logger &&other) noexcept : name_(std::move(other.name_)),
sinks_(std::move(other.sinks_)),
level_(other.level_.load(std::memory_order_relaxed)),
flush_level_(other.flush_level_.load(std::memory_order_relaxed)),
@ -34,13 +34,13 @@ SPDLOG_INLINE logger::logger(logger &&other) SPDLOG_NOEXCEPT : name_(std::move(o
{}
SPDLOG_INLINE logger &logger::operator=(logger other) SPDLOG_NOEXCEPT
SPDLOG_INLINE logger &logger::operator=(logger other) noexcept
{
this->swap(other);
return *this;
}
SPDLOG_INLINE void logger::swap(spdlog::logger &other) SPDLOG_NOEXCEPT
SPDLOG_INLINE void logger::swap(spdlog::logger &other) noexcept
{
name_.swap(other.name_);
sinks_.swap(other.sinks_);

@ -68,10 +68,10 @@ public:
virtual ~logger() = default;
logger(const logger &other);
logger(logger &&other) SPDLOG_NOEXCEPT;
logger &operator=(logger other) SPDLOG_NOEXCEPT;
logger(logger &&other) noexcept;
logger &operator=(logger other) noexcept;
void swap(spdlog::logger &other) SPDLOG_NOEXCEPT;
void swap(spdlog::logger &other) noexcept;
// FormatString is a type derived from fmt::compile_string
template<typename FormatString, typename std::enable_if<fmt::is_compile_string<FormatString>::value, int>::type * = nullptr,

Loading…
Cancel
Save