added wxCStrData::operator- for compatibility with expressions like 'c_str() + n - 2'

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45124 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2007-03-29 18:42:04 +00:00
parent 171d613212
commit f4c90fdfaf

View File

@ -220,6 +220,26 @@ public:
wxCStrData operator+(size_t n) const
{ return wxCStrData(m_str, m_offset + n, m_owned); }
// and these for "str.c_str() + n - 2":
wxCStrData operator-(int n) const
{
wxASSERT_MSG( n <= (int)m_offset,
_T("attempt to construct address before the beginning of the string") );
return wxCStrData(m_str, m_offset - n, m_owned);
}
wxCStrData operator-(long n) const
{
wxASSERT_MSG( n <= (int)m_offset,
_T("attempt to construct address before the beginning of the string") );
return wxCStrData(m_str, m_offset - n, m_owned);
}
wxCStrData operator-(size_t n) const
{
wxASSERT_MSG( n <= (int)m_offset,
_T("attempt to construct address before the beginning of the string") );
return wxCStrData(m_str, m_offset - n, m_owned);
}
// this operator is needed to make expressions like "*c_str()" or
// "*(c_str() + 2)" work
wxUniChar operator*() const;