23 #ifndef STDEXT_PACKEDVECTOR_H
24 #define STDEXT_PACKEDVECTOR_H
33 template<
class T,
class U = u
int8_t>
46 template <
class InputIterator>
47 packed_vector(InputIterator first, InputIterator last) : m_size(last - first), m_data(new T[m_size]) { std::copy(first, last, m_data); }
68 bool empty()
const {
return m_size == 0; }
75 T&
front() {
return m_data[0]; }
76 const T&
front()
const {
return m_data[0]; }
77 T&
back() {
return m_data[m_size-1]; }
78 const T&
back()
const {
return m_data[m_size-1]; }
80 T *
data() {
return m_data; }
81 const T *
data()
const {
return m_data; }
100 T *tmp =
new T[m_size+1];
101 std::copy(m_data, m_data + m_size, tmp);
113 T *tmp =
new T[m_size-1];
114 std::copy(m_data, m_data + m_size - 1, tmp);
121 T *tmp =
new T[m_size+1];
123 std::copy(m_data, m_data + i, tmp);
125 std::copy(m_data + i, m_data + m_size, tmp + i + 1);
133 T *tmp =
new T[m_size-1];
135 std::copy(m_data, m_data + i, tmp);
136 std::copy(m_data + i + 1, m_data + m_size, tmp + i);
145 operator std::vector<T>()
const {
return std::vector<T>(
begin(),
end()); }