diff --git a/llvm/include/llvm/ADT/SmallVector.h b/llvm/include/llvm/ADT/SmallVector.h index 80f7734b86907..5577b09fee89c 100644 --- a/llvm/include/llvm/ADT/SmallVector.h +++ b/llvm/include/llvm/ADT/SmallVector.h @@ -212,17 +212,16 @@ class SmallVectorTemplateCommon void assertSafeToReferenceAfterClear(ItTy, ItTy) {} /// Check whether any part of the range will be invalidated by growing. - void assertSafeToAddRange(const T *From, const T *To) { - if (From == To) - return; - this->assertSafeToAdd(From, To - From); - this->assertSafeToAdd(To - 1, To - From); + template void assertSafeToAddRange(ItTy From, ItTy To) { + if constexpr (std::is_pointer_v && + std::is_same_v>, + T>) { + if (From == To) + return; + this->assertSafeToAdd(From, To - From); + this->assertSafeToAdd(To - 1, To - From); + } } - template < - class ItTy, - std::enable_if_t, T *>::value, - bool> = false> - void assertSafeToAddRange(ItTy, ItTy) {} /// Reserve enough space to add one element, and return the updated element /// pointer in case it was a reference to the storage.