aboutsummaryrefslogtreecommitdiff
path: root/.patch/mcl/0001-assert-macro.patch
blob: 2d7d0dd1b0893b3835c32e03c5be278c4aa744e8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
diff --git a/include/mcl/assert.hpp b/include/mcl/assert.hpp
index f77dbe7..9ec0b9c 100644
--- a/include/mcl/assert.hpp
+++ b/include/mcl/assert.hpp
@@ -23,8 +23,11 @@ template<typename... Ts>

 }  // namespace mcl::detail

+#ifndef UNREACHABLE
 #define UNREACHABLE() ASSERT_FALSE("Unreachable code!")
+#endif

+#ifndef ASSERT
 #define ASSERT(expr)                                                     \
     [&] {                                                                \
         if (std::is_constant_evaluated()) {                              \
@@ -37,7 +40,9 @@ template<typename... Ts>
             }                                                            \
         }                                                                \
     }()
+#endif

+#ifndef ASSERT_MSG
 #define ASSERT_MSG(expr, ...)                                                \
     [&] {                                                                    \
         if (std::is_constant_evaluated()) {                                  \
@@ -50,13 +55,24 @@ template<typename... Ts>
             }                                                                \
         }                                                                    \
     }()
+#endif

+#ifndef ASSERT_FALSE
 #define ASSERT_FALSE(...) ::mcl::detail::assert_terminate("false", __VA_ARGS__)
+#endif

 #if defined(NDEBUG) || defined(MCL_IGNORE_ASSERTS)
-#    define DEBUG_ASSERT(expr) ASSUME(expr)
-#    define DEBUG_ASSERT_MSG(expr, ...) ASSUME(expr)
+#    ifndef DEBUG_ASSERT
+#        define DEBUG_ASSERT(expr) ASSUME(expr)
+#    endif
+#    ifndef DEBUG_ASSERT_MSG
+#        define DEBUG_ASSERT_MSG(expr, ...) ASSUME(expr)
+#    endif
 #else
-#    define DEBUG_ASSERT(expr) ASSERT(expr)
-#    define DEBUG_ASSERT_MSG(expr, ...) ASSERT_MSG(expr, __VA_ARGS__)
+#    ifndef DEBUG_ASSERT
+#        define DEBUG_ASSERT(expr) ASSERT(expr)
+#    endif
+#    ifndef DEBUG_ASSERT_MSG
+#        define DEBUG_ASSERT_MSG(expr, ...) ASSERT_MSG(expr, __VA_ARGS__)
+#    endif
 #endif