فهرست منبع

Made pimpl objects movable but non-copyable

Paul-Louis Ageneau 4 سال پیش
والد
کامیت
d87be3dd8e
1فایلهای تغییر یافته به همراه5 افزوده شده و 0 حذف شده
  1. 5 0
      include/rtc/utils.hpp

+ 5 - 0
include/rtc/utils.hpp

@@ -112,9 +112,14 @@ public:
 	CheshireCat(impl_ptr<T> impl) : mImpl(std::move(impl)) {}
 	template <typename... Args>
 	CheshireCat(Args... args) : mImpl(std::make_shared<T>(std::move(args)...)) {}
+	CheshireCat(CheshireCat<T> &&cc) { *this = std::move(cc); }
+	CheshireCat(const CheshireCat<T> &) = delete;
 
 	virtual ~CheshireCat() = default;
 
+	CheshireCat &operator=(CheshireCat<T> &&cc) { mImpl = std::move(cc->mImpl); };
+	CheshireCat &operator=(const CheshireCat<T> &) = delete;
+
 protected:
 	impl_ptr<T> impl() { return mImpl; }
 	impl_ptr<const T> impl() const { return mImpl; }