aboutsummaryrefslogtreecommitdiff
path: root/lib/avatar.h
diff options
context:
space:
mode:
authorAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-01-02 06:03:26 +0100
committerAlexey Rusakov <Kitsune-Ral@users.sf.net>2022-01-02 06:09:38 +0100
commit7d37d296f942ac993d041b4576ed52265170c4a8 (patch)
treebf36eca388b7fdc363ef21f4defa8ac9c449141d /lib/avatar.h
parentd516280a2b38ccb060e4f7502b873e19b1559ed1 (diff)
downloadlibquotient-7d37d296f942ac993d041b4576ed52265170c4a8.tar.gz
libquotient-7d37d296f942ac993d041b4576ed52265170c4a8.zip
Add ImplPtr and makeImpl
The original (more complex and comprehensive) solution belongs to https://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html - this commit only provides a small wrapper for non-copyable Private class implementations common throughout libQuotient. Unlike the original, default initialisation is made explicit - you have to pass ZeroImpl<Private>() instead (and I firmly believe it's a good thing: normally pointers to Private should not remain nullptr). The reason ZeroImpl<> is not a template variable is quite simple: unique_ptr is non-copyable and so cannot be initialised from; while a template function will initialise the value in-place thanks to copy elision.
Diffstat (limited to 'lib/avatar.h')
-rw-r--r--lib/avatar.h8
1 files changed, 2 insertions, 6 deletions
diff --git a/lib/avatar.h b/lib/avatar.h
index 93f43948..c94dc369 100644
--- a/lib/avatar.h
+++ b/lib/avatar.h
@@ -3,13 +3,12 @@
#pragma once
-#include "quotient_export.h"
+#include "util.h"
#include <QtCore/QUrl>
#include <QtGui/QIcon>
#include <functional>
-#include <memory>
namespace Quotient {
class Connection;
@@ -18,9 +17,6 @@ class QUOTIENT_API Avatar {
public:
explicit Avatar();
explicit Avatar(QUrl url);
- Avatar(Avatar&&);
- ~Avatar();
- Avatar& operator=(Avatar&&);
using get_callback_t = std::function<void()>;
using upload_callback_t = std::function<void(QUrl)>;
@@ -41,6 +37,6 @@ public:
private:
class Private;
- std::unique_ptr<Private> d;
+ ImplPtr<Private> d;
};
} // namespace Quotient