aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/small-vector.mxx5
-rw-r--r--tests/small-vector/driver.cxx1
2 files changed, 6 insertions, 0 deletions
diff --git a/libbutl/small-vector.mxx b/libbutl/small-vector.mxx
index 2a92182..7f9bb1e 100644
--- a/libbutl/small-vector.mxx
+++ b/libbutl/small-vector.mxx
@@ -125,6 +125,11 @@ LIBBUTL_MODEXPORT namespace butl
reserve ();
*this = std::move (v); // Delegate to operator=(&&).
+
+ // Note that in contrast to the move assignment operator, the
+ // constructor must clear the other vector.
+ //
+ v.clear ();
}
small_vector&
diff --git a/tests/small-vector/driver.cxx b/tests/small-vector/driver.cxx
index d79a03b..a8326be 100644
--- a/tests/small-vector/driver.cxx
+++ b/tests/small-vector/driver.cxx
@@ -111,6 +111,7 @@ main ()
s1.emplace_back ("abc");
vector s2 (move (s1));
assert (s2[0] == "abc" && s2.capacity () == 2 && small (s2));
+ assert (s1.empty ()); // The source vector must be empty now.
}
{