Fix ConstexprVector::resize
This commit is contained in:
parent
60e32d73ff
commit
7c3bc48627
|
@ -35,7 +35,7 @@ struct HashIndex
|
|||
size_t new_size = 4;
|
||||
while (new_size < min_size)
|
||||
new_size *= 2;
|
||||
m_entries.resize(new_size, {});
|
||||
m_entries.resize(new_size);
|
||||
}
|
||||
|
||||
using ContainerType = Container<Entry, domain>;
|
||||
|
@ -44,7 +44,7 @@ struct HashIndex
|
|||
{
|
||||
kak_assert(new_size > m_entries.size());
|
||||
ContainerType old_entries = std::move(m_entries);
|
||||
m_entries.resize(new_size, {});
|
||||
m_entries.resize(new_size);
|
||||
for (auto& entry : old_entries)
|
||||
{
|
||||
if (entry.index >= 0)
|
||||
|
|
11
src/meta.hh
11
src/meta.hh
|
@ -57,17 +57,14 @@ struct ConstexprVector
|
|||
constexpr bool empty() const { return m_size == 0; }
|
||||
constexpr size_t size() const { return m_size; }
|
||||
|
||||
constexpr void resize(size_t n, const T& val)
|
||||
constexpr void resize(size_t n, const T& val = {})
|
||||
{
|
||||
if (n >= capacity)
|
||||
throw "capacity exceeded";
|
||||
if (n > m_size)
|
||||
{
|
||||
for (int i = n; i < m_size; ++i)
|
||||
m_data[i] = val;
|
||||
}
|
||||
for (int i = m_size; i < n; ++i)
|
||||
m_data[i] = val;
|
||||
m_size = n;
|
||||
kak_assert(this->size() == m_size);
|
||||
kak_assert(this->size() == m_size); // check for https://gcc.gnu.org/bugzilla/show_bug.cgi?id=79520
|
||||
}
|
||||
|
||||
constexpr T& operator[](size_t i) { return m_data[i]; }
|
||||
|
|
Loading…
Reference in New Issue
Block a user