22#include "util/SourceLocation.hpp"
24#include <boost/log/core/core.hpp>
28#ifndef CLIO_WITHOUT_STACKTRACE
29#include <boost/stacktrace.hpp>
30#include <boost/stacktrace/stacktrace.hpp>
32#include <fmt/format.h>
40 using ActionType = std::function<void(std::string_view)>;
43 static ActionType action;
47 call(std::string_view message);
50 setAction(ActionType newAction);
57 defaultAction(std::string_view message);
71template <
typename... Args>
75 char const* expression,
77 fmt::format_string<Args...> format,
82#ifndef CLIO_WITHOUT_STACKTRACE
83 auto const resultMessage = fmt::format(
84 "Assertion '{}' failed at {}:{}:\n{}\nStacktrace:\n{}",
88 fmt::format(format, std::forward<Args>(args)...),
89 boost::stacktrace::to_string(boost::stacktrace::stacktrace())
92 auto const resultMessage = fmt::format(
93 "Assertion '{}' failed at {}:{}:\n{}",
97 fmt::format(format, std::forward<Args>(args)...)
101 OnAssert::call(resultMessage);
107#define ASSERT(condition, ...) \
108 util::impl::assertImpl(CURRENT_SRC_LOCATION, #condition, static_cast<bool>(condition), __VA_ARGS__)
A class representing the source location of the current code.
Definition SourceLocation.hpp:52
constexpr std::string_view file_name() const
Get the file name.
Definition SourceLocation.hpp:73
constexpr std::size_t line() const
Get the line number.
Definition SourceLocation.hpp:84