[iter] Accept C arrays in hb_iter()
This commit is contained in:
parent
b62e7f9223
commit
0363ce650b
|
@ -45,12 +45,11 @@ struct hb_array_t :
|
|||
* Constructors.
|
||||
*/
|
||||
hb_array_t () : arrayZ (nullptr), length (0) {}
|
||||
hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {}
|
||||
template <typename U = Type, hb_enable_if (hb_is_const (U))>
|
||||
hb_array_t (const hb_array_t<hb_remove_const (Type)> &o) : arrayZ (o.arrayZ), length (o.length) {}
|
||||
hb_array_t (Type *array_, unsigned int length_) : arrayZ (array_), length (length_) {}
|
||||
template <unsigned int length_> hb_array_t (Type (&array_)[length_]) : arrayZ (array_), length (length_) {}
|
||||
|
||||
|
||||
/*
|
||||
* Iterator implementation.
|
||||
*/
|
||||
|
@ -185,7 +184,6 @@ template <typename T, unsigned int length_> inline hb_array_t<T>
|
|||
hb_array (T (&array_)[length_])
|
||||
{ return hb_array_t<T> (array_); }
|
||||
|
||||
|
||||
enum hb_bfind_not_found_t
|
||||
{
|
||||
HB_BFIND_NOT_FOUND_DONT_STORE,
|
||||
|
|
|
@ -112,10 +112,21 @@ struct hb_iter_t
|
|||
/* Returns iterator type of a type. */
|
||||
#define hb_iter_t(Iterable) decltype (hb_declval (Iterable).iter ())
|
||||
|
||||
|
||||
/* TODO Change to function-object. */
|
||||
|
||||
template <typename T>
|
||||
inline hb_iter_t (T)
|
||||
hb_iter (const T& c) { return c.iter (); }
|
||||
|
||||
/* Specialization for C arrays. */
|
||||
template <typename> struct hb_array_t;
|
||||
template <typename Type> inline hb_array_t<Type>
|
||||
hb_iter (Type *array, unsigned int length) { return hb_array_t<Type> (array, length); }
|
||||
template <typename Type, unsigned int length> hb_array_t<Type>
|
||||
hb_iter (Type (&array)[length]) { return hb_iter (array, length); }
|
||||
|
||||
|
||||
/* Mixin to fill in what the subclass doesn't provide. */
|
||||
template <typename iter_t, typename item_t = typename iter_t::__item_t__>
|
||||
struct hb_iter_mixin_t
|
||||
|
|
|
@ -118,6 +118,9 @@ main (int argc, char **argv)
|
|||
|
||||
s2 = s;
|
||||
|
||||
hb_iter (src);
|
||||
hb_iter (src, 2);
|
||||
|
||||
hb_fill (t, 42);
|
||||
hb_copy (t, s);
|
||||
// hb_copy (t, a.iter ());
|
||||
|
@ -139,7 +142,7 @@ main (int argc, char **argv)
|
|||
hb_array_t<hb_vector_t<int> > pa;
|
||||
pa->as_array ();
|
||||
|
||||
+ hb_iter (s)
|
||||
+ hb_iter (src)
|
||||
| hb_map (hb_identity)
|
||||
| hb_filter ()
|
||||
| hb_filter (hb_bool)
|
||||
|
|
Loading…
Reference in New Issue