From 9042a3fb16cb0a000a1fd84ef123f8bbb8e284e2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 31 May 2018 22:29:20 +0200 Subject: [PATCH] Use shrink_to_fit() to implement Shrink() in C++11 build If std::vector<> has shrink_to_fit() method, just use it instead of using the swap-with-a-temporary hack. --- include/wx/dynarray.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/wx/dynarray.h b/include/wx/dynarray.h index d3e1a2bb04..e6d9b8113b 100644 --- a/include/wx/dynarray.h +++ b/include/wx/dynarray.h @@ -164,8 +164,12 @@ public: void Alloc(size_t uiSize) { this->reserve(uiSize); } void Shrink() { +#if !wxUSE_STD_CONTAINERS || __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10) + this->shrink_to_fit(); +#else std::vector tmp(*this); this->swap(tmp); +#endif } size_t GetCount() const { return this->size(); }