aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgatecat <gatecat@ds0.me>2021-12-31 06:57:25 +0000
committerGitHub <noreply@github.com>2021-12-31 06:57:25 +0000
commit3266c51d853bfab6d890739010eb34fdc0fc38c7 (patch)
tree00da8d279f868d4b67a14c9bcdab1da54369523b
parentd65c629fb0da55a8aa897d615551442e6be740d0 (diff)
parent69a4e3e544f3b0cff296a01c51d325d23e265fb1 (diff)
downloadnextpnr-3266c51d853bfab6d890739010eb34fdc0fc38c7.tar.gz
nextpnr-3266c51d853bfab6d890739010eb34fdc0fc38c7.tar.bz2
nextpnr-3266c51d853bfab6d890739010eb34fdc0fc38c7.zip
Merge pull request #890 from YosysHQ/gatecat/ssoarray-move
SSOArray: Implement move and assignment operators
-rw-r--r--common/sso_array.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/common/sso_array.h b/common/sso_array.h
index 1fae6c57..80e7d1c1 100644
--- a/common/sso_array.h
+++ b/common/sso_array.h
@@ -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();