From 93615b9598f6b5e514384327b30acfd6bd8cfcfb Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 30 Dec 2018 19:12:06 -0500 Subject: [PATCH] [iter/meta] Add hb_is_sorted_iterator() --- src/hb-iter.hh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/hb-iter.hh b/src/hb-iter.hh index dc28678e..d0061984 100644 --- a/src/hb-iter.hh +++ b/src/hb-iter.hh @@ -173,7 +173,7 @@ struct hb_is_iterable { enum { value = _hb_is_iterable::value }; } #define hb_is_iterable(Iterable) hb_is_iterable::value -/* hb_is_iterator() */ +/* hb_is_iterator() / hb_is_sorted_iterator() */ template char _hb_is_iterator (...) {}; template int _hb_is_iterator (hb_iter_t *) {}; @@ -181,13 +181,21 @@ template int _hb_is_iterator (hb_iter_t int _hb_is_iterator (hb_iter_t *) {}; template int _hb_is_iterator (hb_iter_t *) {}; static_assert (sizeof (char) != sizeof (int), ""); - template struct hb_is_iterator { enum { - value = sizeof (int) == sizeof (_hb_is_iterator (hb_declval ())) -}; }; + value = sizeof (int) == sizeof (_hb_is_iterator (hb_declval ())) }; }; #define hb_is_iterator(Iter, Item) hb_is_iterator::value +template char _hb_is_sorted_iterator (...) {}; +template int _hb_is_sorted_iterator (hb_sorted_iter_t *) {}; +template int _hb_is_sorted_iterator (hb_sorted_iter_t *) {}; +template int _hb_is_sorted_iterator (hb_sorted_iter_t *) {}; +template int _hb_is_sorted_iterator (hb_sorted_iter_t *) {}; +static_assert (sizeof (char) != sizeof (int), ""); +template +struct hb_is_sorted_iterator { enum { + value = sizeof (int) == sizeof (_hb_is_sorted_iterator (hb_declval ())) }; }; +#define hb_is_sorted_iterator(Iter, Item) hb_is_sorted_iterator::value /* * Algorithms operating on iterators or iteratables. -- GitLab