qxLib
predicates.h
Go to the documentation of this file.
1 /**
2 
3  @file predicates.h
4  @author Khrapov
5  @date 27.12.2025
6  @copyright © Nick Khrapov, 2025. All right reserved.
7 
8 **/
9 #pragma once
10 
11 /**
12  @brief Use this as a condition in any macro above to indicate that this part of your code must never be executed
13 **/
14 #define QX_NO_ENTRY !"No entry"
15 
16 /**
17  @brief Use this as a condition in any macro above to indicate that this part of your code is not ready yet
18 **/
19 #define QX_NOT_IMPLEMENTED !"Not implemented"
20 
21 namespace qx::details
22 {
23 
24 inline bool hit_once(bool& bHit)
25 {
26  const bool bReturn = bHit;
27  bHit = true;
28  return bReturn;
29 }
30 
31 } // namespace qx::details
32 
33 /**
34  @def QX_PREDICATE_HIT_ONCE
35  @brief Predicate to add to a condition in any EXPECT macro. When added, a macro will only hit once.
36  @note It must be after the actual condition.
37  @code
38  QX_EXPECT((a > b || b == 0) || QX_PREDICATE_HIT_ONCE());
39  @endcode
40 **/
41 #define QX_PREDICATE_HIT_ONCE() \
42  []() \
43  { \
44  static bool h = false; \
45  return qx::details::hit_once(h); \
46  }()