1
0
mirror of https://github.com/YosysHQ/nextpnr.git synced 2026-04-17 00:36:08 +00:00

Merge pull request #890 from YosysHQ/gatecat/ssoarray-move

SSOArray: Implement move and assignment operators
This commit is contained in:
gatecat
2021-12-31 06:57:25 +00:00
committed by GitHub

View File

@@ -70,6 +70,26 @@ template <typename T, std::size_t N> class SSOArray
std::copy(other.begin(), other.end(), begin());
}
SSOArray(SSOArray &&other) : m_size(other.size())
{
if (is_heap())
data_heap = other.data_heap;
else
std::copy(other.begin(), other.end(), begin());
other.m_size = 0;
}
SSOArray &operator=(const SSOArray &other)
{
if (&other == this)
return *this;
if (is_heap())
delete[] data_heap;
m_size = other.m_size;
alloc();
std::copy(other.begin(), other.end(), begin());
return *this;
}
template <typename Tother> SSOArray(const Tother &other) : m_size(other.size())
{
alloc();