From d38d401f6a11f20023aa2628723976fa993c16b6 Mon Sep 17 00:00:00 2001 From: Mathias Stearn Date: Mon, 31 Aug 2015 18:40:55 -0400 Subject: SERVER-20233 Custom move assignments must handle self-assignment On MSVC2013 they must be no-ops. On other platforms they can leave the object in a valid but unspecified state. --- src/mongo/util/shared_buffer.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/mongo/util/shared_buffer.h') diff --git a/src/mongo/util/shared_buffer.h b/src/mongo/util/shared_buffer.h index a624f6f8a7c..bd880e62e7c 100644 --- a/src/mongo/util/shared_buffer.h +++ b/src/mongo/util/shared_buffer.h @@ -43,18 +43,15 @@ public: _holder.swap(other._holder); } +#if defined(_MSC_VER) && _MSC_VER < 1900 SharedBuffer(const SharedBuffer&) = default; SharedBuffer& operator=(const SharedBuffer&) = default; - - SharedBuffer(SharedBuffer&& other) : _holder() { - swap(other); - } - + SharedBuffer(SharedBuffer&& other) : _holder(std::move(other._holder)) {} SharedBuffer& operator=(SharedBuffer&& other) { - swap(other); - other._holder.reset(); + _holder = std::move(other._holder); return *this; } +#endif static SharedBuffer allocate(size_t bytes) { return takeOwnership(static_cast(mongoMalloc(sizeof(Holder) + bytes))); -- cgit v1.2.1