File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change 1010#include < string.h>
1111
1212#include < iterator>
13+ #include < type_traits>
1314
1415#pragma pack(push, 1)
1516/* * Implements a drop-in replacement for std::vector<T> which stores up to N
@@ -382,10 +383,14 @@ class prevector {
382383 iterator erase (iterator first, iterator last) {
383384 iterator p = first;
384385 char * endp = (char *)&(*end ());
385- while (p != last) {
386- (*p).~T ();
387- _size--;
388- ++p;
386+ if (!std::is_trivially_destructible<T>::value) {
387+ while (p != last) {
388+ (*p).~T ();
389+ _size--;
390+ ++p;
391+ }
392+ } else {
393+ _size -= last - p;
389394 }
390395 memmove (&(*first), &(*last), endp - ((char *)(&(*last))));
391396 return first;
@@ -426,7 +431,9 @@ class prevector {
426431 }
427432
428433 ~prevector () {
429- clear ();
434+ if (!std::is_trivially_destructible<T>::value) {
435+ clear ();
436+ }
430437 if (!is_direct ()) {
431438 free (_union.indirect );
432439 _union.indirect = NULL ;
You can’t perform that action at this time.
0 commit comments