mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[wpimath] Upgrade to Drake v0.37.0 (#3786)
This commit is contained in:
@@ -88,14 +88,6 @@ 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
|
||||
@@ -122,8 +114,11 @@ 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)>>(); \
|
||||
static_assert( \
|
||||
!std::is_pointer_v<decltype(condition)>, \
|
||||
"When using DRAKE_DEMAND on a raw pointer, always write out " \
|
||||
"DRAKE_DEMAND(foo != nullptr), do not write DRAKE_DEMAND(foo) " \
|
||||
"and rely on implicit pointer-to-bool conversion."); \
|
||||
if (!Trait::Evaluate(condition)) { \
|
||||
::drake::internal::AssertionFailed( \
|
||||
#condition, __func__, __FILE__, __LINE__); \
|
||||
@@ -149,13 +144,15 @@ namespace drake {
|
||||
constexpr bool kDrakeAssertIsArmed = false;
|
||||
constexpr bool kDrakeAssertIsDisarmed = true;
|
||||
} // namespace drake
|
||||
# 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)>>(); \
|
||||
# define DRAKE_ASSERT(condition) do { \
|
||||
typedef ::drake::assert::ConditionTraits< \
|
||||
typename std::remove_cv_t<decltype(condition)>> Trait; \
|
||||
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
|
||||
static_assert( \
|
||||
!std::is_pointer_v<decltype(condition)>, \
|
||||
"When using DRAKE_ASSERT 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."); \
|
||||
} while (0)
|
||||
# define DRAKE_ASSERT_VOID(expression) static_assert( \
|
||||
std::is_convertible_v<decltype(expression), void>, \
|
||||
|
||||
@@ -14,16 +14,6 @@ namespace internal {
|
||||
// Throw an error message.
|
||||
[[noreturn]] void Throw(const char* condition, const char* func,
|
||||
const char* file, int line);
|
||||
|
||||
template <bool>
|
||||
constexpr void DrakeThrowUnlessWasUsedWithRawPointer() {}
|
||||
template<>
|
||||
[[deprecated("\nDRAKE DEPRECATED: When using DRAKE_THROW_UNLESS on a raw"
|
||||
" pointer, always write out DRAKE_THROW_UNLESS(foo != nullptr), do not write"
|
||||
" DRAKE_THROW_UNLESS(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 DrakeThrowUnlessWasUsedWithRawPointer<true>() {}
|
||||
|
||||
} // namespace internal
|
||||
} // namespace drake
|
||||
|
||||
@@ -41,14 +31,17 @@ constexpr void DrakeThrowUnlessWasUsedWithRawPointer<true>() {}
|
||||
/// users, we should err on the side of extra detail about the failure. The
|
||||
/// meaning of "foo" isolated within error message text does not make it
|
||||
/// clear that a null pointer is the proximate cause of the problem.
|
||||
#define DRAKE_THROW_UNLESS(condition) \
|
||||
do { \
|
||||
typedef ::drake::assert::ConditionTraits< \
|
||||
typename std::remove_cv_t<decltype(condition)>> Trait; \
|
||||
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
|
||||
::drake::internal::DrakeThrowUnlessWasUsedWithRawPointer< \
|
||||
std::is_pointer_v<decltype(condition)>>(); \
|
||||
if (!Trait::Evaluate(condition)) { \
|
||||
::drake::internal::Throw(#condition, __func__, __FILE__, __LINE__); \
|
||||
} \
|
||||
#define DRAKE_THROW_UNLESS(condition) \
|
||||
do { \
|
||||
typedef ::drake::assert::ConditionTraits< \
|
||||
typename std::remove_cv_t<decltype(condition)>> Trait; \
|
||||
static_assert(Trait::is_valid, "Condition should be bool-convertible."); \
|
||||
static_assert( \
|
||||
!std::is_pointer_v<decltype(condition)>, \
|
||||
"When using DRAKE_THROW_UNLESS on a raw pointer, always write out " \
|
||||
"DRAKE_THROW_UNLESS(foo != nullptr), do not write DRAKE_THROW_UNLESS" \
|
||||
"(foo) and rely on implicit pointer-to-bool conversion."); \
|
||||
if (!Trait::Evaluate(condition)) { \
|
||||
::drake::internal::Throw(#condition, __func__, __FILE__, __LINE__); \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
Reference in New Issue
Block a user