Made pimpl objects movable but non-copyable

This commit is contained in:
Paul-Louis Ageneau
2021-02-28 14:51:46 +01:00
parent dbee42b099
commit d87be3dd8e

View File

@ -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; }