6
6
7
7
#include < boost/mp11/algorithm.hpp>
8
8
9
- #ifdef __clang__
10
- #define CIB_PRAGMA_SEMI
11
- #else
12
- #define CIB_PRAGMA_SEMI ;
13
- #endif
14
-
15
9
namespace logging {
16
10
template <auto Query, auto Value> struct prop {
17
11
[[nodiscard]] CONSTEVAL static auto query (decltype (Query)) noexcept {
@@ -44,13 +38,16 @@ template <typename... Envs> struct env {
44
38
45
39
namespace detail {
46
40
template <typename T> struct autowrap {
41
+ // NOLINTNEXTLINE(google-explicit-constructor)
47
42
CONSTEVAL autowrap (T t) : value(t) {}
48
43
T value;
49
44
};
50
45
46
+ // NOLINTNEXTLINE(modernize-avoid-c-arrays)
51
47
template <std::size_t N> using str_lit_t = char const (&)[N];
52
48
53
49
template <std::size_t N> struct autowrap <str_lit_t <N>> {
50
+ // NOLINTNEXTLINE(google-explicit-constructor)
54
51
CONSTEVAL autowrap (str_lit_t <N> str) : value(str) {}
55
52
stdx::ct_string<N> value;
56
53
};
@@ -77,15 +74,32 @@ template <std::size_t... Is> struct for_each_pair<std::index_sequence<Is...>> {
77
74
using cib_log_env_t = logging::env<>;
78
75
79
76
// NOLINTBEGIN(cppcoreguidelines-macro-usage)
77
+
78
+ #ifdef __clang__
79
+ #define CIB_PRAGMA_SEMI
80
+ #else
81
+ #define CIB_PRAGMA_SEMI ;
82
+ #endif
83
+
84
+ #define CIB_LOG_ENV_DECL (...) \
85
+ [[maybe_unused]] typedef decltype ([]<logging::detail::autowrap... Args> { \
86
+ using new_env_t = \
87
+ typename logging::detail::for_each_pair<std::make_index_sequence< \
88
+ sizeof ...(Args) / 2 >>::template type<Args...>; \
89
+ return boost::mp11::mp_append<new_env_t , cib_log_env_t >{}; \
90
+ }.template operator ()<__VA_ARGS__>()) cib_log_env_t
91
+
80
92
#define CIB_LOG_ENV (...) \
81
93
STDX_PRAGMA (diagnostic push) \
82
94
STDX_PRAGMA(diagnostic ignored " -Wshadow" ) \
83
- using cib_log_env_t [[maybe_unused]] = \
84
- decltype([]<logging::detail::autowrap... Args> { \
85
- using new_env_t = typename logging::detail::for_each_pair< \
86
- std::make_index_sequence<sizeof ...(Args) / \
87
- 2 >>::template type<Args...>; \
88
- return boost::mp11::mp_append<new_env_t , cib_log_env_t >{}; \
89
- }.template operator ()<__VA_ARGS__>()) CIB_PRAGMA_SEMI \
90
- STDX_PRAGMA(diagnostic pop)
95
+ CIB_LOG_ENV_DECL(__VA_ARGS__) \
96
+ CIB_PRAGMA_SEMI \
97
+ STDX_PRAGMA(diagnostic pop)
98
+
99
+ #define CIB_WITH_LOG_ENV (...) \
100
+ STDX_PRAGMA (diagnostic push) \
101
+ STDX_PRAGMA(diagnostic ignored " -Wshadow" ) \
102
+ if constexpr (CIB_LOG_ENV_DECL(__VA_ARGS__); true ) \
103
+ STDX_PRAGMA (diagnostic pop)
104
+
91
105
// NOLINTEND(cppcoreguidelines-macro-usage)
0 commit comments