10#ifdef DRAKE_DOXYGEN_CXX
41#define DRAKE_ASSERT(condition)
45#define DRAKE_ASSERT_VOID(expression)
49#define DRAKE_DEMAND(condition)
61#define DRAKE_UNREACHABLE()
65#ifdef DRAKE_ASSERT_IS_ARMED
66# error Unexpected DRAKE_ASSERT_IS_ARMED defined.
68#ifdef DRAKE_ASSERT_IS_DISARMED
69# error Unexpected DRAKE_ASSERT_IS_DISARMED defined.
73#if defined(DRAKE_ENABLE_ASSERTS) && defined(DRAKE_DISABLE_ASSERTS)
74# error Conflicting assertion toggles.
75#elif defined(DRAKE_ENABLE_ASSERTS)
76# define DRAKE_ASSERT_IS_ARMED
77#elif defined(DRAKE_DISABLE_ASSERTS) || defined(NDEBUG)
78# define DRAKE_ASSERT_IS_DISARMED
80# define DRAKE_ASSERT_IS_ARMED
86[[noreturn]]
void Abort(
const char* condition,
const char* func,
87 const char*
file,
int line);
90 const char*
file,
int line);
98template <
typename Condition>
100 static constexpr bool is_valid = std::is_convertible_v<Condition, bool>;
108#define DRAKE_UNREACHABLE() \
109 ::drake::internal::Abort( \
110 "Unreachable code was reached?!", __func__, __FILE__, __LINE__)
112#define DRAKE_DEMAND(condition) \
114 typedef ::drake::assert::ConditionTraits< \
115 typename std::remove_cv_t<decltype(condition)>> Trait; \
116 static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
118 !std::is_pointer_v<decltype(condition)>, \
119 "When using DRAKE_DEMAND on a raw pointer, always write out " \
120 "DRAKE_DEMAND(foo != nullptr), do not write DRAKE_DEMAND(foo) " \
121 "and rely on implicit pointer-to-bool conversion."); \
122 if (!Trait::Evaluate(condition)) { \
123 ::drake::internal::AssertionFailed( \
124 #condition, __func__, __FILE__, __LINE__); \
128#ifdef DRAKE_ASSERT_IS_ARMED
134# define DRAKE_ASSERT(condition) DRAKE_DEMAND(condition)
135# define DRAKE_ASSERT_VOID(expression) do { \
137 std::is_convertible_v<decltype(expression), void>, \
138 "Expression should be void."); \
147# define DRAKE_ASSERT(condition) do { \
148 typedef ::drake::assert::ConditionTraits< \
149 typename std::remove_cv_t<decltype(condition)>> Trait; \
150 static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
152 !std::is_pointer_v<decltype(condition)>, \
153 "When using DRAKE_ASSERT on a raw pointer, always write out " \
154 "DRAKE_ASSERT(foo != nullptr), do not write DRAKE_ASSERT(foo) " \
155 "and rely on implicit pointer-to-bool conversion."); \
157# define DRAKE_ASSERT_VOID(expression) static_assert( \
158 std::is_convertible_v<decltype(expression), void>, \
159 "Expression should be void.")
then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file
Definition: ThirdPartyNotices.txt:195
void Abort(const char *condition, const char *func, const char *file, int line)
void AssertionFailed(const char *condition, const char *func, const char *file, int line)
Definition: drake_assertion_error.h:6
constexpr bool kDrakeAssertIsDisarmed
Definition: drake_assert.h:132
constexpr bool kDrakeAssertIsArmed
Definition: drake_assert.h:131
Definition: Eigen_Colamd.h:50
Definition: drake_assert.h:99
static constexpr bool is_valid
Definition: drake_assert.h:100
static bool Evaluate(const Condition &value)
Definition: drake_assert.h:101