Add move operations to wxString

This commit is contained in:
Pavel Tyunin 2021-02-12 12:28:50 +02:00
parent 5b951caa79
commit d00a072dc5
No known key found for this signature in database
GPG key ID: EDFD0FC013D891EC

View file

@ -1090,6 +1090,14 @@ public:
// copy ctor
wxString(const wxString& stringSrc) : m_impl(stringSrc.m_impl) { }
// move ctor
wxString(wxString&& stringSrc) noexcept : m_impl(std::move(stringSrc.m_impl))
{
#if wxUSE_STRING_POS_CACHE
stringSrc.InvalidateCache();
#endif // wxUSE_STRING_POS_CACHE
}
// string containing nRepeat copies of ch
wxString(wxUniChar ch, size_t nRepeat = 1 )
{ assign(nRepeat, ch); }
@ -1718,6 +1726,18 @@ public:
return *this;
}
// move from another wxString
wxString& operator=(wxString&& stringSrc) noexcept
{
m_impl = std::move(stringSrc.m_impl);
#if wxUSE_STRING_POS_CACHE
InvalidateCache();
stringSrc.InvalidateCache();
#endif // wxUSE_STRING_POS_CACHE
return *this;
}
wxString& operator=(const wxCStrData& cstr)
{ return *this = cstr.AsString(); }
// from a character