summaryrefslogtreecommitdiff
path: root/src/mongo/util/shared_buffer.h
diff options
context:
space:
mode:
authorMathias Stearn <mathias@10gen.com>2015-08-31 18:40:55 -0400
committerMathias Stearn <mathias@10gen.com>2015-09-18 14:00:07 -0400
commitd38d401f6a11f20023aa2628723976fa993c16b6 (patch)
treeeb1ca736d2fa15c85e7cf2c7b41941fb2da085a4 /src/mongo/util/shared_buffer.h
parentdd8014ab860189880ba258637e48d2b637de0a5c (diff)
downloadmongo-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.h11
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)));