From f4c90fdfaf2fd2ea1652f958c66e16fc9faff602 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Thu, 29 Mar 2007 18:42:04 +0000 Subject: [PATCH] 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 --- include/wx/string.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/include/wx/string.h b/include/wx/string.h index f1be0afe89..735e75ef77 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -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; -- 2.45.2