Boost logo

Boost :

Subject: Re: [boost] [range] adaptors and member functions pointers
From: Maxim Yanchenko (maximyanchenko_at_[hidden])
Date: 2011-10-12 11:03:10


Jeffrey Lee Hellrung, Jr. <jeffrey.hellrung <at> gmail.com> writes:

> > While transforming and filtering sequences, it's pretty common to call the
> > elements' member functions, so I think it's worth adding some syntactic
> > sugar for range adaptors in order to achieve cleaner syntax.
> >
> > foo_list | transformed(&Foo::description) | filtered(&std::string::size)
> >
>
> It doesn't seem all that onerous to insert a boost::mem_fn [1] in there
> (i.e., "transformed(boost::mem_fn(&Foo:::description))")...or does this not
> work?

Hi Jeff,

Of course this works, as well as STL iterator-based loops versus BOOST_FOREACH.
As I said, this is just a syntactic sugar that makes the code cleaner, and it
does this for quite a frequent case when you call element's member function.

Thanks,
Maxim


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk