CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Assert.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 #define NOP static_cast<void>(nullptr)
6 #define BREAK NOP
8 
9 #ifdef DEBUG
10 #undef BREAK
11 #ifdef TARGET_OS_WINDOWS
12 #define BREAK __debugbreak()
13 #elif defined(TARGET_OS_MAC)
14 #define BREAK __builtin_trap()
15 #else
16 #define BREAK __asm__("int3")
17 #endif
18 #endif
19 
21 #define UNREACHABLE
22 #undef UNREACHABLE
23 
24 #ifdef TARGET_OS_WINDOWS
25 #define UNREACHABLE __assume(false)
26 #else
27 #define UNREACHABLE __builtin_unreachable()
28 #endif
29 
31 #define UNIMPLEMENTED CYB::API::Assert::Unimplemented(__FUNCTION__, __FILE__, __LINE__)
32 
33 namespace CYB {
34  namespace API {
36  class Assert {
37  public:
43  static void HCF[[noreturn]](void) noexcept;
52  static void Unimplemented(const char* const AFunction, const char* const AFile, const unsigned int ALine) noexcept;
59  static void True(const bool AExpression) noexcept;
66  static void False(const bool AExpression) noexcept;
75  template <typename AType> static void Equal(const AType& ALHS, const AType& ARHS) noexcept;
86  template <typename AType, typename... AOtherTypes> static void Equal(const AType& ALHS, const AType& ARHS, AOtherTypes&&... ARHSs) noexcept;
95  template <typename AType> static void NotEqual(const AType& ALHS, const AType& ARHS) noexcept;
104  template <typename AType> static void LessThan(const AType& ALHS, const AType& ARHS) noexcept;
113  template <typename AType> static void LessThanOrEqual(const AType& ALHS, const AType& ARHS) noexcept;
114  };
115  };
116 };
117 #include "Assert.inl"
static void True(const bool AExpression) noexcept
Assertion function. AExpression should always be evaluated.
static void Unimplemented(const char *const AFunction, const char *const AFile, const unsigned int ALine) noexcept
Indicates an unimplemented function, calls HCF if ASSERTION_OVERRIDE is not defined.
Definition: CYBEntry.cpp:44
static void LessThan(const AType &ALHS, const AType &ARHS) noexcept
Less than assertion function. May not be evaluated.
static void NotEqual(const AType &ALHS, const AType &ARHS) noexcept
Unequivalence assertion function. May not be evaluated.
static void HCF(void) noexcept
Indicates unreachable code. Implementation can be overriden by defining ASSERTION_OVERRIDE.
Definition: CYBEntry.cpp:26
static void Equal(const AType &ALHS, const AType &ARHS) noexcept
Equivalence assertion function. May not be evaluated.
static void False(const bool AExpression) noexcept
False assertion function. AExpression should always be evaluated.
Contains assertion functions.
Definition: Assert.hpp:36
static void LessThanOrEqual(const AType &ALHS, const AType &ARHS) noexcept
Less than or equal assertion function. May not be evaluated.