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