aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2017-01-18 16:00:59 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2017-01-18 16:00:59 +0200
commit7b3c9d8c1c10fbd92f121edbdbc85af759101289 (patch)
treecc8db4172d0dc668223e36f547873439a20bb435
parentce492a427632cc7da9607a6a5a53a7a996411226 (diff)
Harden small_vector against misuse
-rw-r--r--butl/small-vector15
1 files changed, 11 insertions, 4 deletions
diff --git a/butl/small-vector b/butl/small-vector
index 8880ffe..5bfbd17 100644
--- a/butl/small-vector
+++ b/butl/small-vector
@@ -7,8 +7,9 @@
#include <vector>
#include <cassert>
-#include <cstddef> // size_t
-#include <utility> // more(), forward()
+#include <cstddef> // size_t
+#include <utility> // more(), forward()
+#include <type_traits> // true_type
namespace butl
{
@@ -108,7 +109,13 @@ namespace butl
// propagate_on_container_copy_assignment = false
// propagate_on_container_move_assignment = false
- // propagate_on_container_swap = false
+
+ // Swap is not supported (see explanation in small_vector::swap()).
+ //
+ using propagate_on_container_swap = std::true_type;
+
+ void
+ swap (small_vector_allocator&) = delete;
// Shouldn't be needed except to satisfy some static_assert's.
//
@@ -223,7 +230,7 @@ namespace butl
// VC's implementation of operator=(&&) (both 14 and 15) frees the
// memory and then reallocated with capacity equal to v.size(). This is
// clearly sub-optimal (the existing buffer could be reused) so we hope
- // this will be fixed eventually.
+ // this will be fixed eventually (VSO#367146).
//
#if defined(_MSC_VER) && _MSC_VER <= 1910
if (v.size () < N)