[iter] Make hb_sorted_array_t work as iter

Ugly, but does the job.
This commit is contained in:
Behdad Esfahbod 2018-12-27 13:29:51 -05:00
parent d6024794fb
commit 570473a345
3 changed files with 24 additions and 2 deletions

View File

@ -194,9 +194,11 @@ enum hb_bfind_not_found_t
template <typename Type>
struct hb_sorted_array_t :
hb_sorted_iter_t<hb_sorted_array_t<Type>, Type>,
hb_array_t<Type>,
hb_iter_mixin_t<hb_sorted_array_t<Type>, Type>
hb_array_t<Type>
{
typedef hb_sorted_iter_t<hb_sorted_array_t<Type>, Type> iter_base_t;
HB_ITER_USING (iter_base_t);
hb_sorted_array_t () : hb_array_t<Type> () {}
hb_sorted_array_t (const hb_array_t<Type> &o) : hb_array_t<Type> (o) {}
hb_sorted_array_t (Type *array_, unsigned int length_) : hb_array_t<Type> (array_, length_) {}

View File

@ -80,6 +80,24 @@ struct hb_iter_t
void operator = (const hb_iter_t &o HB_UNUSED) {}
};
#define HB_ITER_USING(Name) \
using Name::iter; \
using Name::operator bool; \
using Name::len; \
using Name::operator ->; \
using Name::operator *; \
using Name::operator []; \
using Name::operator +=; \
using Name::operator ++; \
using Name::operator -=; \
using Name::operator --; \
using Name::operator +; \
using Name::operator -; \
using Name::is_random_access; \
static_assert (true, "")
/* Base class for sorted iterators. Does not enforce anything.
* Just for class taxonomy and requirements. */
template <typename Iter, typename Item = typename Iter::__item_type__>

View File

@ -109,6 +109,8 @@ main (int argc, char **argv)
test_iterable (v);
hb_set_t st;
test_iterable (st);
hb_sorted_array_t<int> sa;
test_iterable (sa);
return 0;
}