From 7b3c9d8c1c10fbd92f121edbdbc85af759101289 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 18 Jan 2017 16:00:59 +0200 Subject: Harden small_vector against misuse --- butl/small-vector | 15 +++++++++++---- 1 file 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 #include -#include // size_t -#include // more(), forward() +#include // size_t +#include // more(), forward() +#include // 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) -- cgit v1.1