66
77#include < boost/mp11/algorithm.hpp>
88
9- #ifdef __clang__
10- #define CIB_PRAGMA_SEMI
11- #else
12- #define CIB_PRAGMA_SEMI ;
13- #endif
14-
159namespace logging {
1610template <auto Query, auto Value> struct prop {
1711 [[nodiscard]] CONSTEVAL static auto query (decltype (Query)) noexcept {
@@ -44,13 +38,16 @@ template <typename... Envs> struct env {
4438
4539namespace detail {
4640template <typename T> struct autowrap {
41+ // NOLINTNEXTLINE(google-explicit-constructor)
4742 CONSTEVAL autowrap (T t) : value(t) {}
4843 T value;
4944};
5045
46+ // NOLINTNEXTLINE(modernize-avoid-c-arrays)
5147template <std::size_t N> using str_lit_t = char const (&)[N];
5248
5349template <std::size_t N> struct autowrap <str_lit_t <N>> {
50+ // NOLINTNEXTLINE(google-explicit-constructor)
5451 CONSTEVAL autowrap (str_lit_t <N> str) : value(str) {}
5552 stdx::ct_string<N> value;
5653};
@@ -77,15 +74,32 @@ template <std::size_t... Is> struct for_each_pair<std::index_sequence<Is...>> {
7774using cib_log_env_t = logging::env<>;
7875
7976// 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+
8092#define CIB_LOG_ENV (...) \
8193 STDX_PRAGMA (diagnostic push) \
8294 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+
91105// NOLINTEND(cppcoreguidelines-macro-usage)
0 commit comments