[iter] Accept pointer in hb_map()

This commit is contained in:
Behdad Esfahbod 2019-05-08 10:56:09 -07:00
parent 4c9e0c37a3
commit c93eeba9b2
2 changed files with 8 additions and 3 deletions

View File

@ -324,11 +324,11 @@ template <typename Iter, typename Proj,
hb_requires (hb_is_iterator (Iter))> hb_requires (hb_is_iterator (Iter))>
struct hb_map_iter_t : struct hb_map_iter_t :
hb_iter_t<hb_map_iter_t<Iter, Proj>, hb_iter_t<hb_map_iter_t<Iter, Proj>,
decltype (hb_declval (Proj) (hb_declval (typename Iter::item_t)))> decltype (hb_get (hb_declval (Proj), *hb_declval (Iter)))>
{ {
hb_map_iter_t (const Iter& it, Proj f_) : it (it), f (f_) {} hb_map_iter_t (const Iter& it, Proj f_) : it (it), f (f_) {}
typedef decltype (hb_declval (Proj) (hb_declval (typename Iter::item_t))) __item_t__; typedef decltype (hb_get (hb_declval (Proj), *hb_declval (Iter))) __item_t__;
static constexpr bool is_random_access_iterator = Iter::is_random_access_iterator; static constexpr bool is_random_access_iterator = Iter::is_random_access_iterator;
__item_t__ __item__ () const { return hb_get (f.get (), *it); } __item_t__ __item__ () const { return hb_get (f.get (), *it); }
__item_t__ __item_at__ (unsigned i) const { return hb_get (f.get (), it[i]); } __item_t__ __item_at__ (unsigned i) const { return hb_get (f.get (), it[i]); }

View File

@ -177,9 +177,14 @@ main (int argc, char **argv)
hb_array_t<hb_vector_t<int>> pa; hb_array_t<hb_vector_t<int>> pa;
pa->as_array (); pa->as_array ();
hb_map_t m;
+ hb_iter (src) + hb_iter (src)
| hb_map (hb_identity) | hb_map (m)
| hb_map (&m)
| hb_filter () | hb_filter ()
| hb_filter (st)
| hb_filter (&st)
| hb_filter (hb_bool) | hb_filter (hb_bool)
| hb_filter (hb_bool, hb_identity) | hb_filter (hb_bool, hb_identity)
| hb_sink (st) | hb_sink (st)