1 --- wxWidgets-3.1.5/include/wx/string.h.orig 2022-02-24 20:36:30.420389723 +0000
2 +++ wxWidgets-3.1.5/include/wx/string.h 2022-02-24 20:36:37.956572846 +0000
7 +#include <type_traits>
9 #include "wx/wxcrtbase.h" // for wxChar, wxStrlen() etc.
10 #include "wx/strvararg.h"
12 const wxStringCharType *AsInternal() const;
14 // allow expressions like "c_str()[0]":
15 - inline wxUniChar operator[](size_t n) const;
16 - wxUniChar operator[](int n) const { return operator[](size_t(n)); }
17 - wxUniChar operator[](long n) const { return operator[](size_t(n)); }
18 -#ifndef wxSIZE_T_IS_UINT
19 - wxUniChar operator[](unsigned int n) const { return operator[](size_t(n)); }
20 -#endif // size_t != unsigned int
21 + template<typename T, typename = std::enable_if<std::is_integral<T>::value>>
22 + inline wxUniChar operator[](T n) const
24 + // NB: we intentionally use operator[] and not at() here because the former
25 + // works for the terminating NUL while the latter does not
26 + return (*m_str)[m_offset + n];
30 // These operators are needed to emulate the pointer semantics of c_str():
31 // expressions like "wxChar *p = str.c_str() + 1;" should continue to work
32 @@ -1510,29 +1513,13 @@
33 Note that we we must define all of the overloads below to avoid
34 ambiguity when using str[0].
36 - wxUniChar operator[](int n) const
38 - wxUniChar operator[](long n) const
39 + template<typename T, typename = std::enable_if<std::is_integral<T>::value>>
40 + inline wxUniChar operator[](T n) const
42 - wxUniChar operator[](size_t n) const
44 -#ifndef wxSIZE_T_IS_UINT
45 - wxUniChar operator[](unsigned int n) const
47 -#endif // size_t != unsigned int
49 - // operator versions of GetWriteableChar()
50 - wxUniCharRef operator[](int n)
52 - wxUniCharRef operator[](long n)
53 + template<typename T, typename = std::enable_if<std::is_integral<T>::value>>
54 + inline wxUniCharRef operator[](T n)
56 - wxUniCharRef operator[](size_t n)
58 -#ifndef wxSIZE_T_IS_UINT
59 - wxUniCharRef operator[](unsigned int n)
61 -#endif // size_t != unsigned int
65 Overview of wxString conversions, implicit and explicit:
66 @@ -4366,13 +4353,6 @@
67 return (*m_str)[m_offset];
70 -inline wxUniChar wxCStrData::operator[](size_t n) const
72 - // NB: we intentionally use operator[] and not at() here because the former
73 - // works for the terminating NUL while the latter does not
74 - return (*m_str)[m_offset + n];
77 // ----------------------------------------------------------------------------
78 // more wxCStrData operators
79 // ----------------------------------------------------------------------------