[iter] Add hb_is_random_access_iterator()
This commit is contained in:
parent
445364d80a
commit
2658e40ffb
|
@ -159,7 +159,7 @@ struct hb_is_iterable { enum { value = _hb_is_iterable<T, hb_true_t>::value }; }
|
||||||
#define hb_is_iterable(Iterable) hb_is_iterable<Iterable>::value
|
#define hb_is_iterable(Iterable) hb_is_iterable<Iterable>::value
|
||||||
|
|
||||||
|
|
||||||
/* hb_is_iterator() / hb_is_sorted_iterator() */
|
/* hb_is_iterator() / hb_is_random_access_iterator() / hb_is_sorted_iterator() */
|
||||||
|
|
||||||
template <typename Iter>
|
template <typename Iter>
|
||||||
struct _hb_is_iterator_of
|
struct _hb_is_iterator_of
|
||||||
|
@ -177,9 +177,13 @@ struct hb_is_iterator_of { enum {
|
||||||
#define hb_is_iterator_of(Iter, Item) hb_is_iterator_of<Iter, Item>::value
|
#define hb_is_iterator_of(Iter, Item) hb_is_iterator_of<Iter, Item>::value
|
||||||
#define hb_is_iterator(Iter) hb_is_iterator_of (Iter, typename Iter::item_t)
|
#define hb_is_iterator(Iter) hb_is_iterator_of (Iter, typename Iter::item_t)
|
||||||
|
|
||||||
|
#define hb_is_random_access_iterator_of(Iter, Item) \
|
||||||
|
hb_is_iterator_of (Iter, Item) && Iter::is_random_access_iterator
|
||||||
|
#define hb_is_random_access_iterator(Iter) \
|
||||||
|
hb_is_random_access_iterator_of (Iter, typename Iter::item_t)
|
||||||
|
|
||||||
#define hb_is_sorted_iterator_of(Iter, Item) \
|
#define hb_is_sorted_iterator_of(Iter, Item) \
|
||||||
hb_is_iterator_of (Iter, Item) && \
|
hb_is_iterator_of (Iter, Item) && Iter::is_sorted_iterator
|
||||||
Iter::is_sorted_iterator
|
|
||||||
#define hb_is_sorted_iterator(Iter) \
|
#define hb_is_sorted_iterator(Iter) \
|
||||||
hb_is_sorted_iterator_of (Iter, typename Iter::item_t)
|
hb_is_sorted_iterator_of (Iter, typename Iter::item_t)
|
||||||
|
|
||||||
|
|
|
@ -105,6 +105,8 @@ main (int argc, char **argv)
|
||||||
array_iter_t<const int> s2 (v); /* Implicit conversion from vector. */
|
array_iter_t<const int> s2 (v); /* Implicit conversion from vector. */
|
||||||
array_iter_t<int> t (dst);
|
array_iter_t<int> t (dst);
|
||||||
|
|
||||||
|
assert (hb_is_random_access_iterator (array_iter_t<int>));
|
||||||
|
|
||||||
some_array_t<const int> a (src);
|
some_array_t<const int> a (src);
|
||||||
|
|
||||||
s2 = s;
|
s2 = s;
|
||||||
|
|
Loading…
Reference in New Issue