12 #ifndef PLSSVM_DETAIL_ASSERT_HPP_
13 #define PLSSVM_DETAIL_ASSERT_HPP_
18 #include "fmt/color.h"
23 #include <string_view>
38 template <
typename... Args>
43 std::cerr << fmt::format(
44 "Assertion '{}' failed!\n"
49 fmt::format(fmt::emphasis::bold | fmt::fg(fmt::color::green),
"{}", cond_str),
53 fmt::format(fmt::emphasis::bold | fmt::fg(fmt::color::red), msg, std::forward<Args>(args)...))
65 #if defined(PLSSVM_ENABLE_ASSERTS) || !defined(NDEBUG)
66 #define PLSSVM_ASSERT_ENABLED
73 #if defined(PLSSVM_ASSERT_ENABLED)
74 #define PLSSVM_ASSERT(cond, msg, ...) plssvm::detail::check_assertion((cond), (#cond), plssvm::source_location::current(), (msg), ##__VA_ARGS__)
76 #define PLSSVM_ASSERT(cond, msg, ...)
The plssvm::source_location class represents certain information about the source code,...
Definition: source_location.hpp:25
constexpr std::string_view file_name() const noexcept
Returns the function name without additional signature information (i.e. return type and parameters) ...
Definition: source_location.hpp:60
constexpr std::uint_least32_t line() const noexcept
Returns the line number or 0 if no information could be retrieved.
Definition: source_location.hpp:65
constexpr std::string_view function_name() const noexcept
Returns the absolute path name of the file or "unknown" if no information could be retrieved.
Definition: source_location.hpp:54
Namespace containing implementation details. Should not directly be used by users.
Definition: csvm.hpp:27
void check_assertion(const bool cond, const std::string_view cond_str, const source_location &loc, const std::string_view msg, Args &&...args)
Function called by the PLSSVM_ASSERT macro. Checks the assertion condition. If the condition evaluate...
Definition: assert.hpp:39
Implements a custom std::source_location implementation for C++17.