Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion core/templates/local_vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,16 @@ class _WARN_UNUSED_ LocalVector {
}
}

// Can't use `_resize(0)`, since it requires a no-arg-constructor even if it wouldn't be called.
void _clear() {
Comment thread
HolonProduction marked this conversation as resolved.
if constexpr (!std::is_trivially_destructible_v<T>) {
Comment thread
HolonProduction marked this conversation as resolved.
for (U i = 0; i < count; i++) {
data[i].~T();
}
}
count = 0;
}

public:
_FORCE_INLINE_ T *ptr() _LIFETIME_BOUND_ { return data; }
_FORCE_INLINE_ const T *ptr() const _LIFETIME_BOUND_ { return data; }
Expand Down Expand Up @@ -174,7 +184,7 @@ class _WARN_UNUSED_ LocalVector {
[[deprecated("Use reverse() instead")]] void invert() { reverse(); }
#endif

_FORCE_INLINE_ void clear() { resize(0); }
_FORCE_INLINE_ void clear() { _clear(); }
_FORCE_INLINE_ void reset() {
clear();
if (data) {
Expand Down