diff --git a/include/spdlog/common.h b/include/spdlog/common.h index 20ee24a6..318218a2 100644 --- a/include/spdlog/common.h +++ b/include/spdlog/common.h @@ -15,6 +15,7 @@ #include #include #include +#include #if defined(SPDLOG_WCHAR_FILENAMES) || defined(SPDLOG_WCHAR_TO_UTF8_SUPPORT) #include @@ -168,16 +169,19 @@ using filename_t = std::string; err_handler_("Unknown exeption in logger"); \ } -// -// make_unique support -// + +namespace details { +// make_unique support for pre c++14 + #if __cplusplus >= 201402L // C++14 and beyond using std::make_unique; #else template std::unique_ptr make_unique(Args &&... args) { + static_assert(!std::is_array::value, "arrays to not supported" ); return std::unique_ptr(new T(std::forward(args)...)); } #endif +} // namespace details } // namespace spdlog diff --git a/include/spdlog/details/logger_impl.h b/include/spdlog/details/logger_impl.h index a2a3342d..f812c025 100644 --- a/include/spdlog/details/logger_impl.h +++ b/include/spdlog/details/logger_impl.h @@ -49,7 +49,7 @@ inline void spdlog::logger::set_formatter(std::unique_ptr f) inline void spdlog::logger::set_pattern(std::string pattern, pattern_time_type time_type) { - auto new_formatter = spdlog::make_unique(std::move(pattern), time_type); + auto new_formatter = details::make_unique(std::move(pattern), time_type); set_formatter(std::move(new_formatter)); } diff --git a/include/spdlog/details/pattern_formatter.h b/include/spdlog/details/pattern_formatter.h index 9e353ca5..d4e75ed6 100644 --- a/include/spdlog/details/pattern_formatter.h +++ b/include/spdlog/details/pattern_formatter.h @@ -547,7 +547,7 @@ public: std::unique_ptr clone() const override { - return spdlog::make_unique(pattern_, pattern_time_type_, eol_); + return details::make_unique(pattern_, pattern_time_type_, eol_); } void format(const details::log_msg &msg, fmt::memory_buffer &dest) override @@ -592,141 +592,141 @@ private: { // logger name case 'n': - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case 'l': - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case 'L': - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('t'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('v'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('a'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('A'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('b'): case ('h'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('B'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('c'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('C'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('Y'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('D'): case ('x'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('m'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('d'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('H'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('I'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('M'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('S'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('e'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('f'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('F'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('E'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('p'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('r'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('R'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('T'): case ('X'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('z'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('+'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('P'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('i'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('^'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; case ('$'): - formatters_.push_back(spdlog::make_unique()); + formatters_.push_back(details::make_unique()); break; default: // Unknown flag appears as is - formatters_.push_back(spdlog::make_unique('%')); - formatters_.push_back(spdlog::make_unique(flag)); + formatters_.push_back(details::make_unique('%')); + formatters_.push_back(details::make_unique(flag)); break; } } @@ -757,7 +757,7 @@ private: { if (!user_chars) { - user_chars = spdlog::make_unique(); + user_chars = details::make_unique(); } user_chars->add_ch(*it); } diff --git a/include/spdlog/details/registry.h b/include/spdlog/details/registry.h index 52c3bb7d..63baf748 100644 --- a/include/spdlog/details/registry.h +++ b/include/spdlog/details/registry.h @@ -113,7 +113,7 @@ public: { std::lock_guard lock(flusher_mutex_); std::function clbk = std::bind(®istry::flush_all, this); - periodic_flusher_ = spdlog::make_unique(clbk, interval); + periodic_flusher_ = details::make_unique(clbk, interval); } void set_error_handler(log_err_handler handler) diff --git a/include/spdlog/sinks/base_sink.h b/include/spdlog/sinks/base_sink.h index 697758b1..ff29d6c6 100644 --- a/include/spdlog/sinks/base_sink.h +++ b/include/spdlog/sinks/base_sink.h @@ -56,7 +56,7 @@ protected: virtual void set_pattern_(const std::string &pattern) { - set_formatter_(spdlog::make_unique(pattern)); + set_formatter_(details::make_unique(pattern)); } virtual void set_formatter_(std::unique_ptr sink_formatter)