|
Boost : |
From: Jaakko Jarvi (jajarvi_at_[hidden])
Date: 2004-03-03 15:53:39
On Mar 3, 2004, at 3:31 PM, David Abrahams wrote:
> Now, no offense intended, but this is nasty. There's just too much
> extra syntax required for something so simple, plus you have to make
> the type into a pointer just so you can dereference it
I agree, it is nasty.
The guiding principle of lambda was to
provide a 'delayed' version of each C++ operator, which is
what ->* does. As you point out, it can lead to making simple use cases
quite not so simple. It therefore makes sense to provide shortcuts
(sparingly)
for common use cases, like the one you showed.
I'd really like to be able to overload . though :)
Jaakko
> object and its member pointer are reversed. It'd be nice to allow
> something like:
>
> unsigned long n = std::accumulate(
> xs.begin(), xs.end(), 0UL,
> _1 + _2.at(&X::count));
>
> while if _2 were to refer to a pointer type, we could say:
>
> unsigned long n = std::accumulate(
> xs.begin(), xs.end(), 0UL,
> _1 + _2->at(&X::count));
>
Jaakko
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk