diff --git a/include/boost/ut.hpp b/include/boost/ut.hpp index 6a433fd9..4785b405 100644 --- a/include/boost/ut.hpp +++ b/include/boost/ut.hpp @@ -672,8 +672,8 @@ struct fatal_; struct fatal { template - [[nodiscard]] auto operator()(const T& t) const { - return detail::fatal_{t}; + [[nodiscard]] auto operator()(const T& t, const reflection::source_location& sl = reflection::source_location::current()) const { + return detail::fatal_{t, sl}; } }; struct cfg { @@ -2399,13 +2399,15 @@ struct fatal_ : op { using type = fatal_; constexpr explicit fatal_(const TExpr& expr) : expr_{expr} {} + constexpr explicit fatal_(const TExpr& expr, + const reflection::source_location& sl) + : expr_{expr}, location{sl} {} [[nodiscard]] constexpr operator bool() const { if (static_cast(expr_)) { } else { cfg::wip = true; - void(on( - events::assertion{.expr = expr_, .location = cfg::location})); + void(on(events::assertion{.expr = expr_, .location = location})); on(events::fatal_assertion{}); } return static_cast(expr_); @@ -2414,6 +2416,7 @@ struct fatal_ : op { [[nodiscard]] constexpr decltype(auto) get() const { return expr_; } TExpr expr_{}; + reflection::source_location location{}; }; template