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.
This commit is contained in:
Vadim Zeitlin
2018-05-31 22:29:20 +02:00
parent f9721266ae
commit 9042a3fb16

View File

@@ -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<T> tmp(*this);
this->swap(tmp);
#endif
}
size_t GetCount() const { return this->size(); }