diff options
author | Mathias Stearn <mathias@10gen.com> | 2015-08-31 18:40:55 -0400 |
---|---|---|
committer | Mathias Stearn <mathias@10gen.com> | 2015-09-18 14:00:07 -0400 |
commit | d38d401f6a11f20023aa2628723976fa993c16b6 (patch) | |
tree | eb1ca736d2fa15c85e7cf2c7b41941fb2da085a4 /src/mongo/util/shared_buffer.h | |
parent | dd8014ab860189880ba258637e48d2b637de0a5c (diff) | |
download | mongo-d38d401f6a11f20023aa2628723976fa993c16b6.tar.gz |
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.
Diffstat (limited to 'src/mongo/util/shared_buffer.h')
-rw-r--r-- | src/mongo/util/shared_buffer.h | 11 |
1 files changed, 4 insertions, 7 deletions
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<char*>(mongoMalloc(sizeof(Holder) + bytes))); |