|
|
|
@ -10,6 +10,7 @@
@@ -10,6 +10,7 @@
|
|
|
|
|
#include <string.h> |
|
|
|
|
|
|
|
|
|
#include <iterator> |
|
|
|
|
#include <type_traits> |
|
|
|
|
|
|
|
|
|
#pragma pack(push, 1) |
|
|
|
|
/** Implements a drop-in replacement for std::vector<T> which stores up to N
|
|
|
|
@ -382,11 +383,15 @@ public:
@@ -382,11 +383,15 @@ public:
|
|
|
|
|
iterator erase(iterator first, iterator last) { |
|
|
|
|
iterator p = first; |
|
|
|
|
char* endp = (char*)&(*end()); |
|
|
|
|
if (!std::is_trivially_destructible<T>::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:
@@ -426,7 +431,9 @@ public:
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
~prevector() { |
|
|
|
|
if (!std::is_trivially_destructible<T>::value) { |
|
|
|
|
clear(); |
|
|
|
|
} |
|
|
|
|
if (!is_direct()) { |
|
|
|
|
free(_union.indirect); |
|
|
|
|
_union.indirect = NULL; |
|
|
|
|