File tree Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Expand file tree Collapse file tree 2 files changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -70,15 +70,14 @@ ALWAYS_INLINE static auto log(TArgs &&...args) -> void {
7070 CIB_LOG (logging::default_flavor_t , logging::level::ERROR, __VA_ARGS__)
7171
7272#define CIB_FATAL (MSG, ...) \
73- [] { \
74- constexpr auto str = sc::format (MSG##_sc __VA_OPT__ (, ) __VA_ARGS__); \
73+ [](auto &&str) { \
7574 logging::log<logging::default_flavor_t , logging::level::FATAL, \
7675 cib_log_env_t >(__FILE__, __LINE__, str); \
77- str.apply ([]<typename S, typename ... Args>(S s, Args... args) { \
76+ FWD ( str) .apply ([]<typename S, typename ... Args>(S s, Args... args) { \
7877 constexpr auto cts = stdx::ct_string_from_type (s); \
7978 stdx::panic<cts>(args...); \
8079 }); \
81- }()
80+ }(sc::format(MSG##_sc __VA_OPT__ (, ) __VA_ARGS__) )
8281
8382#define CIB_ASSERT (expr ) \
8483 ((expr) ? void (0 ) : CIB_FATAL(" Assertion failure: " #expr))
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ bool panicked{};
1616struct injected_handler {
1717 template <stdx::ct_string Why, typename ... Ts>
1818 static auto panic (Ts &&...) noexcept -> void {
19- static_assert (std::string_view{Why} == " Hello" );
19+ static_assert (std::string_view{Why}. starts_with ( " Hello" ) );
2020 panicked = true ;
2121 }
2222};
@@ -55,3 +55,10 @@ TEST_CASE("CIB_FATAL pre-formats arguments passed to panic", "[log]") {
5555 CIB_FATAL (" {}" , " Hello" _sc);
5656 CHECK (panicked);
5757}
58+
59+ TEST_CASE (" CIB_FATAL can format stack arguments" , " [log]" ) {
60+ panicked = false ;
61+ auto x = 42 ;
62+ CIB_FATAL (" Hello {}" , x);
63+ CHECK (panicked);
64+ }
You can’t perform that action at this time.
0 commit comments