diff --git a/src/prevector.h b/src/prevector.h index 6b2f578f5c..9eb6f8c68f 100644 --- a/src/prevector.h +++ b/src/prevector.h @@ -10,6 +10,7 @@ #include #include +#include #pragma pack(push, 1) /** Implements a drop-in replacement for std::vector which stores up to N @@ -382,10 +383,14 @@ public: iterator erase(iterator first, iterator last) { iterator p = first; char* endp = (char*)&(*end()); - while (p != last) { - (*p).~T(); - _size--; - ++p; + if (!std::is_trivially_destructible::value) { + while (p != last) { + (*p).~T(); + _size--; + ++p; + } + } else { + _size -= last - p; } memmove(&(*first), &(*last), endp - ((char*)(&(*last)))); return first; @@ -426,7 +431,9 @@ public: } ~prevector() { - clear(); + if (!std::is_trivially_destructible::value) { + clear(); + } if (!is_direct()) { free(_union.indirect); _union.indirect = NULL;