|
@@ -179,9 +179,11 @@ namespace tinystl {
|
|
|
Alloc::static_deallocate(b->first, sizeof(T)*capacity);
|
|
Alloc::static_deallocate(b->first, sizeof(T)*capacity);
|
|
|
b->capacity = b->first;
|
|
b->capacity = b->first;
|
|
|
} else if (b->capacity != b->last) {
|
|
} else if (b->capacity != b->last) {
|
|
|
|
|
+ const size_t capacity = (size_t)(b->capacity - b->first);
|
|
|
const size_t size = (size_t)(b->last - b->first);
|
|
const size_t size = (size_t)(b->last - b->first);
|
|
|
T* newfirst = (T*)Alloc::static_allocate(sizeof(T) * size);
|
|
T* newfirst = (T*)Alloc::static_allocate(sizeof(T) * size);
|
|
|
buffer_move_urange(newfirst, b->first, b->last);
|
|
buffer_move_urange(newfirst, b->first, b->last);
|
|
|
|
|
+ Alloc::static_deallocate(b->first, sizeof(T) * capacity);
|
|
|
b->first = newfirst;
|
|
b->first = newfirst;
|
|
|
b->last = newfirst + size;
|
|
b->last = newfirst + size;
|
|
|
b->capacity = b->last;
|
|
b->capacity = b->last;
|
|
@@ -225,6 +227,26 @@ namespace tinystl {
|
|
|
new(placeholder(), where) T();
|
|
new(placeholder(), where) T();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ template<typename T, typename Alloc, typename Param>
|
|
|
|
|
+ static inline void buffer_append(buffer<T, Alloc>* b, const Param* param) {
|
|
|
|
|
+ if (b->capacity != b->last) {
|
|
|
|
|
+ new(placeholder(), b->last) T(*param);
|
|
|
|
|
+ ++b->last;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ buffer_insert(b, b->last, param, param + 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ template<typename T, typename Alloc>
|
|
|
|
|
+ static inline void buffer_append(buffer<T, Alloc>* b) {
|
|
|
|
|
+ if (b->capacity != b->last) {
|
|
|
|
|
+ new(placeholder(), b->last) T();
|
|
|
|
|
+ ++b->last;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ buffer_insert(b, b->last, 1);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
template<typename T, typename Alloc>
|
|
template<typename T, typename Alloc>
|
|
|
static inline T* buffer_erase(buffer<T, Alloc>* b, T* first, T* last) {
|
|
static inline T* buffer_erase(buffer<T, Alloc>* b, T* first, T* last) {
|
|
|
typedef T* pointer;
|
|
typedef T* pointer;
|