librados: add move operations to IoCtx

Signed-off-by: Casey Bodley <cbodley@redhat.com>
This commit is contained in:
Casey Bodley 2018-10-23 17:26:11 -04:00 committed by Yehuda Sadeh
parent 238f0ef4a4
commit cfd66c5f89
2 changed files with 15 additions and 0 deletions
src
include/rados
librados

View File

@ -710,6 +710,8 @@ namespace librados
static void from_rados_ioctx_t(rados_ioctx_t p, IoCtx &pool);
IoCtx(const IoCtx& rhs);
IoCtx& operator=(const IoCtx& rhs);
IoCtx(IoCtx&& rhs) noexcept;
IoCtx& operator=(IoCtx&& rhs) noexcept;
~IoCtx();

View File

@ -1051,6 +1051,19 @@ librados::IoCtx& librados::IoCtx::operator=(const IoCtx& rhs)
return *this;
}
librados::IoCtx::IoCtx(IoCtx&& rhs) noexcept
: io_ctx_impl(std::exchange(rhs.io_ctx_impl, nullptr))
{
}
librados::IoCtx& librados::IoCtx::operator=(IoCtx&& rhs) noexcept
{
if (io_ctx_impl)
io_ctx_impl->put();
io_ctx_impl = std::exchange(rhs.io_ctx_impl, nullptr);
return *this;
}
librados::IoCtx::~IoCtx()
{
close();