Iros
 
Loading...
Searching...
No Matches
assert_interface.h
Go to the documentation of this file.
1#pragma once
2
3#ifndef DI_CUSTOM_ASSERT_HANDLER
4#ifdef DI_NO_USE_STD
5#error "Cannot use DI_NO_USE_STD with DI_CUSTOM_ASSERT_HANDLER"
6#endif
7#include <cstdlib>
8#include <iostream>
9
11
12namespace di::assert::detail {
13[[noreturn]] inline void assert_fail(char const* source_text, char const* lhs_message, char const* rhs_message,
15 std::cerr << "\033[31;1mASSERT\033[0m: " << source_text;
16 std::cerr << ": " << loc.function_name() << ": " << loc.file_name() << ":" << loc.line() << ":" << loc.column()
17 << std::endl;
18 if (lhs_message) {
19 std::cerr << "\033[1mLHS\033[0m: " << lhs_message << std::endl;
20 }
21 if (rhs_message) {
22 std::cerr << "\033[1mRHS\033[0m: " << rhs_message << std::endl;
23 }
24 std::abort();
25}
26}
27#else
29
30namespace di::assert::detail {
31void assert_fail(char const* source_text, char const* lhs_message, char const* rhs_message, util::SourceLocation loc);
32}
33#endif
Definition source_location.h:10
constexpr auto function_name() const -> char const *
Definition source_location.h:29
constexpr auto line() const -> unsigned int
Definition source_location.h:26
constexpr auto column() const -> unsigned int
Definition source_location.h:27
constexpr auto file_name() const -> char const *
Definition source_location.h:28
Definition assert_binary.h:20
void assert_fail(char const *source_text, char const *lhs_message, char const *rhs_message, util::SourceLocation loc)
Definition assert_interface.h:13