… | |
… | |
20 | return first; |
20 | return first; |
21 | } |
21 | } |
22 | |
22 | |
23 | #include <new> |
23 | #include <new> |
24 | |
24 | |
25 | #if __cplusplus >= 201103L |
25 | #if ECB_CPP11 |
26 | #include <type_traits> |
26 | #include <type_traits> |
27 | #endif |
27 | #endif |
28 | |
28 | |
29 | // original version taken from MICO, but this has been completely rewritten |
29 | // original version taken from MICO, but this has been completely rewritten |
30 | // known limitations w.r.t. std::vector |
30 | // known limitations w.r.t. std::vector |
… | |
… | |
63 | |
63 | |
64 | // we shamelessly optimise for "simple" types. everything |
64 | // we shamelessly optimise for "simple" types. everything |
65 | // "not simple enough" will use the slow path. |
65 | // "not simple enough" will use the slow path. |
66 | static bool is_simple_enough () |
66 | static bool is_simple_enough () |
67 | { |
67 | { |
68 | #if __cplusplus >= 201103L |
68 | #if ECB_CPP11 |
69 | return std::is_trivially_assignable<T, T>::value |
69 | return std::is_trivially_assignable<T, T>::value |
70 | && std::is_trivially_constructable<T>::value |
70 | && std::is_trivially_constructable<T>::value |
71 | && std::is_trivially_copyable<T>::value |
71 | && std::is_trivially_copyable<T>::value |
72 | && std::is_trivially_destructible<T>::value; |
72 | && std::is_trivially_destructible<T>::value; |
73 | #elif ECB_GCC_VERSION(4,4) |
73 | #elif ECB_GCC_VERSION(4,4) |
… | |
… | |
320 | return buf + at; |
320 | return buf + at; |
321 | } |
321 | } |
322 | |
322 | |
323 | iterator erase (iterator first, iterator last) |
323 | iterator erase (iterator first, iterator last) |
324 | { |
324 | { |
325 | size_t n = last - first; |
325 | size_type n = last - first; |
|
|
326 | size_type c = end () - last; |
326 | |
327 | |
327 | if (is_simple_enough ()) |
328 | if (is_simple_enough ()) |
328 | memmove (first, last, sizeof (T) * n); |
329 | memmove (first, last, sizeof (T) * c); |
329 | else |
330 | else |
330 | copy<iterator> (first, last, n, cop_set); |
331 | copy<iterator> (first, last, c, cop_set); |
331 | |
332 | |
332 | sze -= n; |
333 | sze -= n; |
333 | destruct (buf + sze, n); |
334 | destruct (buf + sze, n); |
334 | |
335 | |
335 | return first; |
336 | return first; |