|
Boost Users : |
From: someuserat (marktutt_at_[hidden])
Date: 2002-09-19 20:28:18
--- In Boost-Users_at_y..., "Peter Dimov" <pdimov_at_m...> wrote:
> > for_each(widgetset_.begin(),widgetset_.end(),i->insert);
> > }
>
> I think that you need bind(&WidgetMap::insert, i, _1) here.
Thanks! I figured that one out this morning,
[...]
> maps_.erase(remove_if(maps_.begin(),maps_.end(),(boost::mem_fn
(&WidgetMap::g
> etIndexedMember)).equals(d)));
>
> This is getting harder.
>
> bind(&DataMember::equals, bind(&WidgetMap::getIndexedMember, _1), d)
>
> would be my guess. Easier would be to define a helper function
>
> bool memberEquals(WidgetMap const & m, DataMemberPtr d)
> {
> return m.getIndexedMember().equals(d);
> }
>
> and then use
>
> bind(memberEquals, _1, d) in dropWidgetMember.
I actually ended up figuring out how to write a function object class
to do something similar. This has been a good learning experience!
Is there a down side to the function object approach over the helper
function? From what I could tell, the helper function had to be a
global function, which just didn't seem right.
Thanks,
Mark
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net