]> git.saurik.com Git - wxWidgets.git/blobdiff - include/wx/string.h
added wxCStrData::operator- for compatibility with expressions like 'c_str() + n...
[wxWidgets.git] / include / wx / string.h
index f1be0afe8956b9835c3891a01d5f78f2b1dccad2..735e75ef7709c6de6338e8110d286b0cfb499c84 100644 (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;