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 10
10
#include < string.h>
11
11
12
12
#include < iterator>
13
+ #include < type_traits>
13
14
14
15
#pragma pack(push, 1)
15
16
/* * Implements a drop-in replacement for std::vector<T> which stores up to N
@@ -382,10 +383,14 @@ class prevector {
382
383
iterator erase (iterator first, iterator last) {
383
384
iterator p = first;
384
385
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;
389
394
}
390
395
memmove (&(*first), &(*last), endp - ((char *)(&(*last))));
391
396
return first;
@@ -426,7 +431,9 @@ class prevector {
426
431
}
427
432
428
433
~prevector () {
429
- clear ();
434
+ if (!std::is_trivially_destructible<T>::value) {
435
+ clear ();
436
+ }
430
437
if (!is_direct ()) {
431
438
free (_union.indirect );
432
439
_union.indirect = NULL ;
You can’t perform that action at this time.
0 commit comments