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>
33#include <fmt/format.h>
41 using ActionType = std::function<void(std::string_view)>;
44 static ActionType action;
48 call(std::string_view message);
51 setAction(ActionType newAction);
58 defaultAction(std::string_view message);
72template <
typename... Args>
76 char const* expression,
78 fmt::format_string<Args...> format,
83#ifndef CLIO_WITHOUT_STACKTRACE
84 auto const resultMessage = fmt::format(
85 "Assertion '{}' failed at {}:{}:\n{}\nStacktrace:\n{}",
89 fmt::format(format, std::forward<Args>(args)...),
90 boost::stacktrace::to_string(boost::stacktrace::stacktrace())
93 auto const resultMessage = fmt::format(
94 "Assertion '{}' failed at {}:{}:\n{}",
98 fmt::format(format, std::forward<Args>(args)...)
102 OnAssert::call(resultMessage);
108#define ASSERT(condition, ...) \
109 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