google-explicit-constructor

This commit is contained in:
Daniel Chabrowski 2018-02-25 01:40:46 +01:00
parent 1e1ca23101
commit ad624432d8
7 changed files with 18 additions and 18 deletions

View File

@ -106,7 +106,6 @@ using level_hasher = std::hash<int>;
} //level } //level
// //
// Async overflow policy - block by default. // Async overflow policy - block by default.
// //
@ -139,12 +138,14 @@ std::string errno_str(int err_num);
class spdlog_ex : public std::exception class spdlog_ex : public std::exception
{ {
public: public:
spdlog_ex(const std::string& msg):_msg(msg) explicit spdlog_ex(std::string msg) : _msg(std::move(msg))
{} {}
spdlog_ex(const std::string& msg, int last_errno) spdlog_ex(const std::string& msg, int last_errno)
{ {
_msg = msg + ": " + details::os::errno_str(last_errno); _msg = msg + ": " + details::os::errno_str(last_errno);
} }
const char* what() const SPDLOG_NOEXCEPT override const char* what() const SPDLOG_NOEXCEPT override
{ {
return _msg.c_str(); return _msg.c_str();
@ -163,5 +164,4 @@ using filename_t = std::wstring;
using filename_t = std::string; using filename_t = std::string;
#endif #endif
} //spdlog } //spdlog

View File

@ -67,7 +67,7 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
msg_id(other.msg_id) msg_id(other.msg_id)
{} {}
async_msg(async_msg_type m_type): explicit async_msg(async_msg_type m_type):
level(level::info), level(level::info),
thread_id(0), thread_id(0),
msg_type(m_type), msg_type(m_type),
@ -91,7 +91,7 @@ async_msg(async_msg&& other) SPDLOG_NOEXCEPT:
async_msg& operator=(const async_msg& other) = delete; async_msg& operator=(const async_msg& other) = delete;
// construct from log_msg // construct from log_msg
async_msg(const details::log_msg& m): explicit async_msg(const details::log_msg& m):
level(m.level), level(m.level),
time(m.time), time(m.time),
thread_id(m.thread_id), thread_id(m.thread_id),

View File

@ -53,13 +53,13 @@ namespace spdlog
namespace details namespace details
{ {
template<typename T> template <typename T>
class mpmc_bounded_queue class mpmc_bounded_queue
{ {
public: public:
using item_type = T; using item_type = T;
mpmc_bounded_queue(size_t buffer_size)
explicit mpmc_bounded_queue(size_t buffer_size)
:max_size_(buffer_size), :max_size_(buffer_size),
buffer_(new cell_t[buffer_size]), buffer_(new cell_t[buffer_size]),
buffer_mask_(buffer_size - 1) buffer_mask_(buffer_size - 1)
@ -79,6 +79,8 @@ public:
delete[] buffer_; delete[] buffer_;
} }
mpmc_bounded_queue(mpmc_bounded_queue const&) = delete;
void operator=(mpmc_bounded_queue const&) = delete;
bool enqueue(T&& data) bool enqueue(T&& data)
{ {
@ -167,9 +169,6 @@ private:
cacheline_pad_t pad2_; cacheline_pad_t pad2_;
std::atomic<size_t> dequeue_pos_; std::atomic<size_t> dequeue_pos_;
cacheline_pad_t pad3_; cacheline_pad_t pad3_;
mpmc_bounded_queue(mpmc_bounded_queue const&) = delete;
void operator= (mpmc_bounded_queue const&) = delete;
}; };
} // ns details } // ns details

View File

@ -27,7 +27,7 @@ struct null_atomic_int
int value; int value;
null_atomic_int() = default; null_atomic_int() = default;
null_atomic_int(int val):value(val) explicit null_atomic_int(int val) : value(val)
{} {}
int load(std::memory_order) const int load(std::memory_order) const

View File

@ -26,9 +26,12 @@ namespace spdlog
{ {
namespace details namespace details
{ {
template <class Mutex> class registry_t template <class Mutex>
class registry_t
{ {
public: public:
registry_t<Mutex>(const registry_t<Mutex>&) = delete;
registry_t<Mutex>& operator=(const registry_t<Mutex>&) = delete;
void register_logger(std::shared_ptr<logger> logger) void register_logger(std::shared_ptr<logger> logger)
{ {
@ -38,7 +41,6 @@ public:
_loggers[logger_name] = logger; _loggers[logger_name] = logger;
} }
std::shared_ptr<logger> get(const std::string& logger_name) std::shared_ptr<logger> get(const std::string& logger_name)
{ {
std::lock_guard<Mutex> lock(_mutex); std::lock_guard<Mutex> lock(_mutex);
@ -111,6 +113,7 @@ public:
std::lock_guard<Mutex> lock(_mutex); std::lock_guard<Mutex> lock(_mutex);
_loggers.clear(); _loggers.clear();
} }
std::shared_ptr<logger> create(const std::string& logger_name, sinks_init_list sinks) std::shared_ptr<logger> create(const std::string& logger_name, sinks_init_list sinks)
{ {
return create(logger_name, sinks.begin(), sinks.end()); return create(logger_name, sinks.begin(), sinks.end());
@ -195,8 +198,6 @@ public:
private: private:
registry_t<Mutex>() = default; registry_t<Mutex>() = default;
registry_t<Mutex>(const registry_t<Mutex>&) = delete;
registry_t<Mutex>& operator=(const registry_t<Mutex>&) = delete;
void throw_if_exists(const std::string &logger_name) void throw_if_exists(const std::string &logger_name)
{ {

View File

@ -25,7 +25,7 @@ namespace spdlog
class logger class logger
{ {
public: public:
logger(const std::string& logger_name, sink_ptr single_sink); logger(const std::string& name, sink_ptr single_sink);
logger(const std::string& name, sinks_init_list); logger(const std::string& name, sinks_init_list);
template<class It> template<class It>
logger(const std::string& name, const It& begin, const It& end); logger(const std::string& name, const It& begin, const It& end);

View File

@ -26,7 +26,7 @@ template <class Mutex>
class ansicolor_sink : public base_sink<Mutex> class ansicolor_sink : public base_sink<Mutex>
{ {
public: public:
ansicolor_sink(FILE* file): target_file_(file) explicit ansicolor_sink(FILE* file) : target_file_(file)
{ {
should_do_colors_ = details::os::in_terminal(file) && details::os::is_color_terminal(); should_do_colors_ = details::os::in_terminal(file) && details::os::is_color_terminal();
colors_[level::trace] = cyan; colors_[level::trace] = cyan;