Wizards: Add move semantics to shared data class template

Fixes: QTCREATORBUG-30526
Change-Id: I9a3423fcbbc19a26876bf1d6c863285639449df3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Christian Kandeler
2024-08-22 17:55:52 +02:00
parent e9b160c025
commit 71e0f7e24d
2 changed files with 21 additions and 1 deletions

View File

@@ -1,5 +1,10 @@
%{JS: Cpp.licenseTemplate()}\
#include "%{JS: Util.relativeFilePath('%{Path}/%{HdrFileName}', '%{Path}' + '/' + Util.path('%{SrcFileName}'))}"
@if '%{IncludeQSharedData}'
#include <utility>
@endif
%{JS: Cpp.openNamespaces('%{Class}')}
@if '%{IncludeQSharedData}'
class %{CN}Data : public QSharedData
@@ -32,10 +37,23 @@ public:
}
%{CN}::%{CN}(%{CN} &&rhs)
: data{std::move(rhs.data)}
{
}
%{CN} &%{CN}::operator=(const %{CN} &rhs)
{
if (this != &rhs)
data.operator=(rhs.data);
data = rhs.data;
return *this;
}
%{CN} &%{CN}::operator=(%{CN} &&rhs)
{
if (this != &rhs)
data = std::move(rhs.data);
return *this;
}

View File

@@ -44,7 +44,9 @@ public:
@endif
@if '%{IncludeQSharedData}'
%{CN}(const %{CN} &);
%{CN}(%{CN} &&);
%{CN} &operator=(const %{CN} &);
%{CN} &operator=(%{CN} &&);
~%{CN}();
@endif
@if %{isQObject}