… | |
… | |
98 | template<class I> |
98 | template<class I> |
99 | static void cop_new (iterator a, I b) { new (a) T (*b); } |
99 | static void cop_new (iterator a, I b) { new (a) T (*b); } |
100 | template<class I> |
100 | template<class I> |
101 | static void cop_set (iterator a, I b) { *a = *b ; } |
101 | static void cop_set (iterator a, I b) { *a = *b ; } |
102 | |
102 | |
103 | template<class I> |
|
|
104 | static void copy_lower (iterator dst, I src, size_type n, void (*op)(iterator, I ) = cop_new) |
|
|
105 | { |
|
|
106 | while (n--) |
|
|
107 | op (dst++, src++); |
|
|
108 | } |
|
|
109 | |
|
|
110 | static void copy_lower (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator) = cop_new) |
|
|
111 | { |
|
|
112 | if (is_simple_enough ()) |
|
|
113 | memmove (dst, src, sizeof (T) * n); |
|
|
114 | else |
|
|
115 | copy_lower<iterator> (dst, src, n, cop_new); |
|
|
116 | } |
|
|
117 | |
|
|
118 | static void copy_higher (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator) = cop_new) |
103 | static void copy_higher (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator) = cop_new) |
119 | { |
104 | { |
120 | if (is_simple_enough ()) |
105 | if (is_simple_enough ()) |
121 | memmove (dst, src, sizeof (T) * n); |
106 | memmove (dst, src, sizeof (T) * n); |
122 | else |
107 | else |
… | |
… | |
125 | } |
110 | } |
126 | |
111 | |
127 | template<class I> |
112 | template<class I> |
128 | static void copy (iterator dst, I src, size_type n, void (*op)(iterator, I) = cop_new) |
113 | static void copy (iterator dst, I src, size_type n, void (*op)(iterator, I) = cop_new) |
129 | { |
114 | { |
130 | copy_lower<I> (dst, src, n, op); |
115 | while (n--) |
|
|
116 | op (dst++, src++); |
131 | } |
117 | } |
132 | |
118 | |
133 | static void copy (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator) = cop_new) |
119 | static void copy (iterator dst, iterator src, size_type n, void (*op)(iterator, iterator) = cop_new) |
134 | { |
120 | { |
135 | if (is_simple_enough ()) |
121 | if (is_simple_enough ()) |
… | |
… | |
338 | |
324 | |
339 | void erase (iterator first, iterator last) |
325 | void erase (iterator first, iterator last) |
340 | { |
326 | { |
341 | size_t n = last - first; |
327 | size_t n = last - first; |
342 | |
328 | |
343 | copy_lower (last, first, end () - last, cop_set); |
329 | if (is_simple_enough ()) |
|
|
330 | memmove (first, last, sizeof (T) * n); |
|
|
331 | else |
|
|
332 | copy<iterator> (first, last, n, cop_new); |
|
|
333 | |
344 | sze -= n; |
334 | sze -= n; |
345 | destruct (buf + sze, n); |
335 | destruct (buf + sze, n); |
346 | } |
336 | } |
347 | |
337 | |
348 | void erase (iterator pos) |
338 | void erase (iterator pos) |