Define wxShrinkToFit() helper for wxVector<>
Unlike member shrink_to_fit(), this function is always defined, even when wxVector is pre-C++11 std::vector<>.
This commit is contained in:
@@ -111,12 +111,7 @@ public:
|
|||||||
|
|
||||||
void Shrink()
|
void Shrink()
|
||||||
{
|
{
|
||||||
#if !wxUSE_STD_CONTAINERS || __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10)
|
wxShrinkToFit(*this);
|
||||||
this->shrink_to_fit();
|
|
||||||
#else
|
|
||||||
base_vec tmp(*this);
|
|
||||||
this->swap(tmp);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t GetCount() const { return this->size(); }
|
size_t GetCount() const { return this->size(); }
|
||||||
|
@@ -669,6 +669,19 @@ void wxVectorSort(wxVector<T>& v)
|
|||||||
|
|
||||||
#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
|
#endif // wxUSE_STD_CONTAINERS/!wxUSE_STD_CONTAINERS
|
||||||
|
|
||||||
|
// Define vector::shrink_to_fit() equivalent which can be always used, even
|
||||||
|
// when using pre-C++11 std::vector.
|
||||||
|
template<typename T>
|
||||||
|
inline void wxShrinkToFit(wxVector<T>& v)
|
||||||
|
{
|
||||||
|
#if !wxUSE_STD_CONTAINERS || __cplusplus >= 201103L || wxCHECK_VISUALC_VERSION(10)
|
||||||
|
v.shrink_to_fit();
|
||||||
|
#else
|
||||||
|
wxVector<T> tmp(v);
|
||||||
|
v.swap(tmp);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
#if WXWIN_COMPATIBILITY_2_8
|
#if WXWIN_COMPATIBILITY_2_8
|
||||||
#define WX_DECLARE_VECTORBASE(obj, cls) typedef wxVector<obj> cls
|
#define WX_DECLARE_VECTORBASE(obj, cls) typedef wxVector<obj> cls
|
||||||
#define _WX_DECLARE_VECTOR(obj, cls, exp) WX_DECLARE_VECTORBASE(obj, cls)
|
#define _WX_DECLARE_VECTOR(obj, cls, exp) WX_DECLARE_VECTORBASE(obj, cls)
|
||||||
|
Reference in New Issue
Block a user