Initialize function-local static variables using "T& t = *new T"

This commit is contained in:
lixingcong 2024-08-17 22:33:53 +08:00
parent 5ebfc92730
commit d89fff6c7c
No known key found for this signature in database
GPG Key ID: FA7E30D337A91091
3 changed files with 4 additions and 4 deletions

View File

@ -12,7 +12,7 @@ namespace details {
struct console_mutex {
using mutex_t = std::mutex;
static mutex_t &mutex() {
static mutex_t s_mutex;
static mutex_t& s_mutex = *new mutex_t;
return s_mutex;
}
};
@ -20,7 +20,7 @@ struct console_mutex {
struct console_nullmutex {
using mutex_t = null_mutex;
static mutex_t &mutex() {
static mutex_t s_mutex;
static mutex_t& s_mutex = *new mutex_t;
return s_mutex;
}
};

View File

@ -234,7 +234,7 @@ SPDLOG_INLINE void registry::set_levels(log_levels levels, level::level_enum *gl
}
SPDLOG_INLINE registry &registry::instance() {
static registry s_instance;
static registry& s_instance = *new registry;
return s_instance;
}

View File

@ -38,7 +38,7 @@ public:
static void clear() { get_context().clear(); }
static mdc_map_t &get_context() {
static thread_local mdc_map_t context;
static thread_local mdc_map_t& context = *new mdc_map_t;
return context;
}
};