mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-06 07:17:42 -05:00
Add a smoke test to Span in debug builds to recover from non-empty nullptr Span.
This commit is contained in:
@@ -51,8 +51,17 @@ public:
|
||||
std::is_same<T, wchar_t>>;
|
||||
|
||||
_FORCE_INLINE_ constexpr Span() = default;
|
||||
_FORCE_INLINE_ constexpr Span(const T *p_ptr, uint64_t p_len) :
|
||||
_ptr(p_ptr), _len(p_len) {}
|
||||
|
||||
_FORCE_INLINE_ Span(const T *p_ptr, uint64_t p_len) :
|
||||
_ptr(p_ptr), _len(p_len) {
|
||||
#ifdef DEBUG_ENABLED
|
||||
// TODO In c++20, make this check run only in non-consteval, and make this constructor constexpr.
|
||||
if (_ptr == nullptr && _len > 0) {
|
||||
ERR_PRINT("Internal bug, please report: Span was created from nullptr with size > 0. Recovering by using size = 0.");
|
||||
_len = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// Allows creating Span directly from C arrays and string literals.
|
||||
template <size_t N>
|
||||
|
||||
Reference in New Issue
Block a user