From cc5bd48eff6f3a12b6066179d1b00d6404c9d921 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 6 Apr 2007 22:56:06 +0000 Subject: [PATCH] added operator-(const wxChar *, const wxCStrData&) to allow compilation of the code doing "p - s.c_str()" where p is a pointer into the string s git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@45290 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/string.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/include/wx/string.h b/include/wx/string.h index 72900dcfb1..208f343912 100644 --- a/include/wx/string.h +++ b/include/wx/string.h @@ -2347,6 +2347,22 @@ inline wxUniChar wxCStrData::operator[](size_t n) const return m_str->at(m_offset + n); } +// ---------------------------------------------------------------------------- +// more wxCStrData operators +// ---------------------------------------------------------------------------- + +// we need to define those to allow "size_t pos = p - s.c_str()" where p is +// some pointer into the string +inline size_t operator-(const char *p, const wxCStrData& cs) +{ + return p - cs.AsChar(); +} + +inline size_t operator-(const wchar_t *p, const wxCStrData& cs) +{ + return p - cs.AsWChar(); +} + // ---------------------------------------------------------------------------- // implementation of wx[W]CharBuffer inline methods using wxCStrData // ---------------------------------------------------------------------------- -- 2.45.2