HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
assert.hpp
1// Copyright Take Vos 2020-2021.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#ifndef ASSERT_HPP
6#define ASSERT_HPP
7
8#pragma once
9
10#include "architecture.hpp"
11#include "debugger.hpp"
12#include "utils.hpp"
13#include <exception>
14
15namespace tt {
16
21#define tt_assert(expression, ...) \
22 do { \
23 if (!(expression)) { \
24 if constexpr (__VA_OPT__(!) true) { \
25 [[unlikely]] tt_debugger_abort(#expression); \
26 } else { \
27 [[unlikely]] tt_debugger_abort(__VA_ARGS__); \
28 } \
29 } \
30 } while (false)
31
32#if TT_BUILD_TYPE == TT_BT_DEBUG
37#define tt_axiom(expression, ...) tt_assert(expression __VA_OPT__(,) __VA_ARGS__)
38
42#define tt_no_default() [[unlikely]] tt_debugger_abort("tt_no_default()")
43
44#else
45
50#define tt_axiom(expression, ...) tt_assume(expression)
51
55#define tt_no_default() tt_unreachable()
56#endif
57
61#define tt_static_no_default() []<bool Flag = false>(){ static_assert(Flag); }()
62
66#define tt_not_implemented() [[unlikely]] tt_debugger_abort("tt_not_implemented()")
67
71#define tt_static_not_implemented() tt_static_no_default()
72
73} // namespace tt
74
75#endif