Try fixing MSVC 2008 build

Fixes https://github.com/harfbuzz/harfbuzz/issues/1374
This commit is contained in:
Behdad Esfahbod 2018-11-10 16:35:39 -05:00
parent f2e942f302
commit b4c6113032
1 changed files with 10 additions and 2 deletions

View File

@ -337,8 +337,16 @@ struct UnsizedArrayOf
{
HB_NO_CREATE_COPY_ASSIGN_TEMPLATE (UnsizedArrayOf, Type);
inline const Type& operator [] (unsigned int i) const { return arrayZ[i]; }
inline Type& operator [] (unsigned int i) { return arrayZ[i]; }
/* Unlikely other places, use "int i" instead of "unsigned int i" for our
* indexing operator. For two reasons:
* 1. For UnsizedArrayOf, it's not totally unimaginable to want to look
* at items before the start of current array.
* 2. Fixes MSVC 2008 "overloads have similar conversions" issue with the
* built-in operator [] that takes int, in expressions like sizeof(array[0])).
* I suppose I could fix that by replacing 0 with 0u, but like this fix
* more now. */
inline const Type& operator [] (int i) const { return arrayZ[i]; }
inline Type& operator [] (int i) { return arrayZ[i]; }
template <typename T> inline operator T * (void) { return arrayZ; }
template <typename T> inline operator const T * (void) const { return arrayZ; }