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:
parent
f9721266ae
commit
9042a3fb16
1 changed files with 4 additions and 0 deletions
|
|
@ -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(); }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue