Add explicit_operator

Fixes https://github.com/harfbuzz/harfbuzz/issues/1127
This commit is contained in:
Behdad Esfahbod 2018-08-12 12:21:56 -07:00
parent 470acb6c32
commit f9a3eab810
2 changed files with 15 additions and 2 deletions

View File

@ -72,7 +72,7 @@ struct Iter<T *>
array (array_), length (length_) {}
/* Emptiness. */
inline operator bool (void) const { return bool (length); }
explicit_operator inline operator bool (void) const { return bool (length); }
/* Current item. */
inline T &operator * (void)

View File

@ -125,7 +125,20 @@ struct _hb_alignof
#define alignof(x) (_hb_alignof<x>::value)
#endif
#endif // __cplusplus < 201103L
/* https://github.com/harfbuzz/harfbuzz/issues/1127 */
#ifndef explicit_operator
#define explicit_operator
#endif
#else /* __cplusplus >= 201103L */
/* https://github.com/harfbuzz/harfbuzz/issues/1127 */
#ifndef explicit_operator
#define explicit_operator explicit
#endif
#endif /* __cplusplus < 201103L */
#if (defined(__GNUC__) || defined(__clang__)) && defined(__OPTIMIZE__)
#define likely(expr) (__builtin_expect (!!(expr), 1))