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