mirror of
https://github.com/NoelFB/blah.git
synced 2024-11-29 17:08:56 +08:00
fixed missing <cstring> #include for vector.h
This commit is contained in:
parent
d91658aa46
commit
10c1c39419
|
@ -2,6 +2,7 @@
|
||||||
#include <blah/common.h>
|
#include <blah/common.h>
|
||||||
#include <initializer_list>
|
#include <initializer_list>
|
||||||
#include <new>
|
#include <new>
|
||||||
|
#include <cstring>
|
||||||
|
|
||||||
namespace Blah
|
namespace Blah
|
||||||
{
|
{
|
||||||
|
@ -182,14 +183,21 @@ namespace Blah
|
||||||
|
|
||||||
T* new_buffer = (T*)::operator new (sizeof(T) * new_capacity);
|
T* new_buffer = (T*)::operator new (sizeof(T) * new_capacity);
|
||||||
|
|
||||||
|
if constexpr (std::is_trivially_copyable<T>())
|
||||||
|
{
|
||||||
|
memcpy(new_buffer, m_buffer, m_count * sizeof(T));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for (int i = 0; i < m_count; i++)
|
for (int i = 0; i < m_count; i++)
|
||||||
{
|
{
|
||||||
if (i < new_capacity)
|
if (i < new_capacity)
|
||||||
new (new_buffer + i) T(std::move(m_buffer[i]));
|
new (new_buffer + i) T(std::move(m_buffer[i]));
|
||||||
m_buffer[i].~T();
|
m_buffer[i].~T();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
::operator delete (m_buffer, sizeof(T)* m_capacity);
|
::operator delete (m_buffer, sizeof(T) * m_capacity);
|
||||||
|
|
||||||
m_buffer = new_buffer;
|
m_buffer = new_buffer;
|
||||||
m_capacity = new_capacity;
|
m_capacity = new_capacity;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user