diff --git a/octa/vector.h b/octa/vector.h index a11f4c1..186f071 100644 --- a/octa/vector.h +++ b/octa/vector.h @@ -33,6 +33,11 @@ namespace octa { *this = v; } + Vector(Vector &&v): p_buf(v.p_buf), p_len(v.p_len), p_cap(v.p_cap) { + v.p_buf = NULL; + v.p_len = v.p_cap = 0; + } + ~Vector() { clear(); } @@ -139,6 +144,13 @@ namespace octa { return p_buf[p_len++]; } + template + T &emplace_back(U &&...args) { + if (p_len == p_cap) reserve(p_len + 1); + new (&p_buf[p_len]) T(args...); + return p_buf[p_len++]; + } + void pop() { if (octa::IsClass::value) { p_buf[--p_len].~T();