Adds move constructor and move assignment operator to the librbd::Image.
Also marks copy ctor/assign op as deleted, and makes them public for better compiler diagnostics.
Signed-off-by: Anatoly Scheglov <finch@mts.ru>
Image();
~Image();
+ // non-copyable
+ Image(const Image& rhs) = delete;
+ Image& operator=(const Image& rhs) = delete;
+
+ // moveable
+ Image(Image&& rhs) noexcept;
+ Image& operator=(Image&& rhs) noexcept;
+
int close();
int aio_close(RBD::AioCompletion *c);
private:
friend class RBD;
- Image(const Image& rhs);
- const Image& operator=(const Image& rhs);
-
image_ctx_t ctx;
};
#include "librbd/io/ReadResult.h"
#include <algorithm>
#include <string>
+#include <utility>
#include <vector>
#ifdef WITH_LTTNG
close();
}
+ Image::Image(Image&& rhs) noexcept : ctx{std::exchange(rhs.ctx, nullptr)}
+ {
+ }
+
+ Image& Image::operator=(Image&& rhs) noexcept
+ {
+ Image tmp(std::move(rhs));
+ std::swap(ctx, tmp.ctx);
+ return *this;
+ }
+
int Image::close()
{
int r = 0;