mirror of
https://github.com/mutouyun/cpp-ipc.git
synced 2025-12-06 16:56:45 +08:00
fix: error C2535 for vs2015
This commit is contained in:
parent
093597ca66
commit
16c16ad3d0
@ -6,14 +6,14 @@
|
|||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
void BM_imp_log_no_output(benchmark::State& state) {
|
void BM_imp_log_no_output(benchmark::State& state) {
|
||||||
imp::log::gripper log {__func__, {}};
|
imp::log::grip log {__func__, {}};
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
log.debug("hello log.");
|
log.debug("hello log.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void BM_imp_log_gripper(benchmark::State& state) {
|
void BM_imp_log_gripper(benchmark::State& state) {
|
||||||
imp::log::gripper log {__func__, {}};
|
imp::log::grip log {__func__, {}};
|
||||||
for (auto _ : state) {
|
for (auto _ : state) {
|
||||||
log.info("hello log.");
|
log.info("hello log.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,15 +53,11 @@ template <typename T>
|
|||||||
class has_fn_output {
|
class has_fn_output {
|
||||||
static std::integral_constant<out_type, out_none> check(...);
|
static std::integral_constant<out_type, out_none> check(...);
|
||||||
|
|
||||||
template <typename U>
|
template <typename U, typename = decltype(u->output(log::level::trace, std::declval<std::string>()))>
|
||||||
static auto check(U *u)
|
static std::integral_constant<out_type, out_string> check(U *u);
|
||||||
-> decltype(u->output(log::level::trace, std::declval<std::string>()),
|
|
||||||
std::integral_constant<out_type, out_string>{});
|
|
||||||
|
|
||||||
template <typename U>
|
template <typename U, typename = decltype(u->output(std::declval<log::context>()))>
|
||||||
static auto check(U *u)
|
static std::integral_constant<out_type, out_context> check(U *u);
|
||||||
-> decltype(u->output(log::level::trace, std::declval<log::context>()),
|
|
||||||
std::integral_constant<out_type, out_context>{});
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
using type = decltype(check(static_cast<T *>(nullptr)));
|
using type = decltype(check(static_cast<T *>(nullptr)));
|
||||||
@ -129,20 +125,25 @@ public:
|
|||||||
void output(context) noexcept;
|
void output(context) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief Standard console output.
|
||||||
class LIBIMP_EXPORT std_t {
|
class LIBIMP_EXPORT std_t {
|
||||||
public:
|
public:
|
||||||
void output(log::level, std::string &&) noexcept;
|
void output(log::level, std::string &&) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief Standard console output object.
|
||||||
LIBIMP_EXPORT extern std_t std_out;
|
LIBIMP_EXPORT extern std_t std_out;
|
||||||
|
|
||||||
class gripper {
|
/**
|
||||||
|
* @brief Log information grips.
|
||||||
|
*/
|
||||||
|
class grip {
|
||||||
printer printer_;
|
printer printer_;
|
||||||
char const *func_;
|
char const *func_;
|
||||||
level level_limit_;
|
level level_limit_;
|
||||||
|
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &output(log::level l, Fmt &&ft, A &&... args) noexcept {
|
grip &output(log::level l, Fmt &&ft, A &&... args) noexcept {
|
||||||
if (!printer_ || (enum_cast(l) < enum_cast(level_limit_))) {
|
if (!printer_ || (enum_cast(l) < enum_cast(level_limit_))) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@ -163,33 +164,33 @@ class gripper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
gripper(char const *func, printer printer = std_out, level level_limit = level::info) noexcept
|
grip(char const *func, printer printer = std_out, level level_limit = level::info) noexcept
|
||||||
: printer_ (printer)
|
: printer_ (printer)
|
||||||
, func_ (func)
|
, func_ (func)
|
||||||
, level_limit_(level_limit) {}
|
, level_limit_(level_limit) {}
|
||||||
|
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &trace(Fmt &&ft, A &&... args) noexcept {
|
grip &trace(Fmt &&ft, A &&... args) noexcept {
|
||||||
return output(log::level::trace, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
return output(log::level::trace, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
||||||
}
|
}
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &debug(Fmt &&ft, A &&... args) noexcept {
|
grip &debug(Fmt &&ft, A &&... args) noexcept {
|
||||||
return output(log::level::debug, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
return output(log::level::debug, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
||||||
}
|
}
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &info(Fmt &&ft, A &&... args) noexcept {
|
grip &info(Fmt &&ft, A &&... args) noexcept {
|
||||||
return output(log::level::info, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
return output(log::level::info, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
||||||
}
|
}
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &warning(Fmt &&ft, A &&... args) noexcept {
|
grip &warning(Fmt &&ft, A &&... args) noexcept {
|
||||||
return output(log::level::warning, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
return output(log::level::warning, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
||||||
}
|
}
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &error(Fmt &&ft, A &&... args) noexcept {
|
grip &error(Fmt &&ft, A &&... args) noexcept {
|
||||||
return output(log::level::error, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
return output(log::level::error, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
||||||
}
|
}
|
||||||
template <typename Fmt, typename... A>
|
template <typename Fmt, typename... A>
|
||||||
gripper &failed(Fmt &&ft, A &&... args) noexcept {
|
grip &failed(Fmt &&ft, A &&... args) noexcept {
|
||||||
return output(log::level::failed, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
return output(log::level::failed, std::forward<Fmt>(ft), std::forward<A>(args)...);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -197,4 +198,4 @@ public:
|
|||||||
} // namespace log
|
} // namespace log
|
||||||
LIBIMP_NAMESPACE_END_
|
LIBIMP_NAMESPACE_END_
|
||||||
|
|
||||||
#define LIBIMP_LOG_(...) ::LIBIMP_::log::gripper log {__func__, __VA_ARGS__}
|
#define LIBIMP_LOG_(...) ::LIBIMP_::log::grip log {__func__, __VA_ARGS__}
|
||||||
@ -28,7 +28,7 @@ inline LPSECURITY_ATTRIBUTES get_sa() {
|
|||||||
|
|
||||||
initiator() {
|
initiator() {
|
||||||
using namespace ::LIBIMP_;
|
using namespace ::LIBIMP_;
|
||||||
log::gripper log {"get_sa"};
|
log::grip log {"get_sa"};
|
||||||
if (!::InitializeSecurityDescriptor(&sd_, SECURITY_DESCRIPTOR_REVISION)) {
|
if (!::InitializeSecurityDescriptor(&sd_, SECURITY_DESCRIPTOR_REVISION)) {
|
||||||
log.error("failed: InitializeSecurityDescriptor(SECURITY_DESCRIPTOR_REVISION). error = {}", sys::error());
|
log.error("failed: InitializeSecurityDescriptor(SECURITY_DESCRIPTOR_REVISION). error = {}", sys::error());
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -13,7 +13,7 @@ namespace {
|
|||||||
/**
|
/**
|
||||||
* @brief Check that bytes is not 0 and that the alignment is a power of two.
|
* @brief Check that bytes is not 0 and that the alignment is a power of two.
|
||||||
*/
|
*/
|
||||||
bool verify_args(::LIBIMP_::log::gripper &log, std::size_t bytes, std::size_t alignment) noexcept {
|
bool verify_args(::LIBIMP_::log::grip &log, std::size_t bytes, std::size_t alignment) noexcept {
|
||||||
if (bytes == 0) {
|
if (bytes == 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -74,7 +74,7 @@ TEST(log, log_printer) {
|
|||||||
|
|
||||||
TEST(log, gripper) {
|
TEST(log, gripper) {
|
||||||
{
|
{
|
||||||
imp::log::gripper log {__func__};
|
imp::log::grip log {__func__};
|
||||||
log.info("hello");
|
log.info("hello");
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user