提交 0268db11 编写于 作者: B Behdad Esfahbod

[map] Use hb_invoke() with pointer-to-method

上级 8f79a575
...@@ -73,7 +73,7 @@ struct ...@@ -73,7 +73,7 @@ struct
/* Pointer-to-member-function. */ /* Pointer-to-member-function. */
template <typename Appl, typename Val1, typename ...Vals> auto template <typename Appl, typename Val1, typename ...Vals> auto
impl (Appl&& a, hb_priority<2>, Val1 &&v1, Vals &&...vs) const HB_AUTO_RETURN impl (Appl&& a, hb_priority<2>, Val1 &&v1, Vals &&...vs) const HB_AUTO_RETURN
(hb_deref_pointer (hb_forward<Val1> (v1)).*hb_forward<Appl> (a) (hb_forward<Vals> (vs)...)) ((hb_deref_pointer (hb_forward<Val1> (v1)).*hb_forward<Appl> (a)) (hb_forward<Vals> (vs)...))
/* Pointer-to-member. */ /* Pointer-to-member. */
template <typename Appl, typename Val> auto template <typename Appl, typename Val> auto
...@@ -86,6 +86,9 @@ struct ...@@ -86,6 +86,9 @@ struct
(hb_deref_pointer (hb_forward<Appl> (a)) (hb_forward<Vals> (vs)...)) (hb_deref_pointer (hb_forward<Appl> (a)) (hb_forward<Vals> (vs)...))
public: public:
template <typename Appl, typename Val1, typename ...Vals> auto
impl2 (Appl&& a, hb_priority<2>, Val1 &&v1, Vals &&...vs) const HB_AUTO_RETURN
(hb_deref_pointer (hb_forward<Val1> (v1)).*hb_forward<Appl> (a) (hb_forward<Vals> (vs)...))
template <typename Appl, typename ...Vals> auto template <typename Appl, typename ...Vals> auto
operator () (Appl&& a, Vals &&...vs) const HB_AUTO_RETURN operator () (Appl&& a, Vals &&...vs) const HB_AUTO_RETURN
......
...@@ -122,7 +122,7 @@ struct hb_hashmap_t ...@@ -122,7 +122,7 @@ struct hb_hashmap_t
return false; return false;
} }
+ hb_iter (new_items, new_size) + hb_iter (new_items, new_size)
| hb_apply ([] (item_t &_) { _.clear (); }) /* TODO make pointer-to-methods invokable. */ | hb_apply (&item_t::clear)
; ;
unsigned int old_size = mask + 1; unsigned int old_size = mask + 1;
...@@ -193,7 +193,7 @@ struct hb_hashmap_t ...@@ -193,7 +193,7 @@ struct hb_hashmap_t
return; return;
if (items) if (items)
+ hb_iter (items, mask + 1) + hb_iter (items, mask + 1)
| hb_apply ([] (item_t &_) { _.clear (); }) /* TODO make pointer-to-methods invokable. */ | hb_apply (&item_t::clear)
; ;
population = occupancy = 0; population = occupancy = 0;
......
...@@ -34,6 +34,11 @@ test_func (int a, char **b) ...@@ -34,6 +34,11 @@ test_func (int a, char **b)
return b ? b[a] : nullptr; return b ? b[a] : nullptr;
} }
struct A
{
void a () {}
};
int int
main (int argc, char **argv) main (int argc, char **argv)
{ {
...@@ -54,5 +59,8 @@ main (int argc, char **argv) ...@@ -54,5 +59,8 @@ main (int argc, char **argv)
hb_invoke (test_func, 0, nullptr); hb_invoke (test_func, 0, nullptr);
A a;
hb_invoke (&A::a, a);
return 0; return 0;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册