From a61c9cfdfab35d0d8f88328b1871e7e7b834a324 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 19 Apr 2018 14:31:26 +0300 Subject: [PATCH] Make assignment operator unambiguous Copying a std::deque would cause a compilation failure due to ambiguity between the copy-assignment and move-assignment operators. Explicitly constructing a temporary object retains the strong exception guarantee but prevents the ambiguity. --- include/maxscale/buffer.hh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/include/maxscale/buffer.hh b/include/maxscale/buffer.hh index 8fa0feaca..43a4d5b5c 100644 --- a/include/maxscale/buffer.hh +++ b/include/maxscale/buffer.hh @@ -337,9 +337,10 @@ public: * * @see Buffer::copy_from */ - Buffer& operator = (Buffer rhs) + Buffer& operator = (const Buffer& rhs) { - swap(rhs); + Buffer temp(rhs); + swap(temp); return *this; }