[wpimath] Upgrade to Drake v0.34.0 (#3607)

This commit is contained in:
Tyler Veness
2021-09-29 15:39:47 -07:00
committed by GitHub
parent c7594c9111
commit 4676648b78
3 changed files with 51 additions and 6 deletions

View File

@@ -88,6 +88,14 @@ namespace internal {
// Report an assertion failure; will either Abort(...) or throw.
[[noreturn]] void AssertionFailed(const char* condition, const char* func,
const char* file, int line);
template <bool>
constexpr void DrakeAssertWasUsedWithRawPointer() {}
template<>
[[deprecated("\nDRAKE DEPRECATED: When using DRAKE_ASSERT or DRAKE_DEMAND on"
" a raw pointer, always write out DRAKE_ASSERT(foo != nullptr), do not write"
" DRAKE_ASSERT(foo) and rely on implicit pointer-to-bool conversion."
"\nThe deprecated code will be removed from Drake on or after 2021-12-01.")]]
constexpr void DrakeAssertWasUsedWithRawPointer<true>() {}
} // namespace internal
namespace assert {
// Allows for specialization of how to bool-convert Conditions used in
@@ -114,6 +122,8 @@ struct ConditionTraits {
typedef ::drake::assert::ConditionTraits< \
typename std::remove_cv_t<decltype(condition)>> Trait; \
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
::drake::internal::DrakeAssertWasUsedWithRawPointer< \
std::is_pointer_v<decltype(condition)>>(); \
if (!Trait::Evaluate(condition)) { \
::drake::internal::AssertionFailed( \
#condition, __func__, __FILE__, __LINE__); \
@@ -139,10 +149,14 @@ namespace drake {
constexpr bool kDrakeAssertIsArmed = false;
constexpr bool kDrakeAssertIsDisarmed = true;
} // namespace drake
# define DRAKE_ASSERT(condition) static_assert( \
::drake::assert::ConditionTraits< \
typename std::remove_cv_t<decltype(condition)>>::is_valid, \
"Condition should be bool-convertible.");
# define DRAKE_ASSERT(condition) do { \
static_assert( \
::drake::assert::ConditionTraits< \
typename std::remove_cv_t<decltype(condition)>>::is_valid, \
"Condition should be bool-convertible."); \
::drake::internal::DrakeAssertWasUsedWithRawPointer< \
std::is_pointer_v<decltype(condition)>>(); \
} while (0)
# define DRAKE_ASSERT_VOID(expression) static_assert( \
std::is_convertible_v<decltype(expression), void>, \
"Expression should be void.")