Boost logo

Boost :

From: David Abrahams (david.abrahams_at_[hidden])
Date: 2002-07-09 14:33:33

From: "David B. Held" <dheld_at_[hidden]>

> "Peter Dimov" <pdimov_at_[hidden]> wrote in message
> news:004c01c22777$4e1389d0$1d00a8c0_at_pdimov2...
> > [...]
> > template<class T, class R, class U> function<R>
> > const & p, R (U::*pmf) ())
> > {
> > return bind(pmf, p);
> > }
> > [...]
> Very nice. Just two questions...Paul, can you create the additional
> overloads with the preprocessor, and Peter, would you object to this
> perhaps going into a separate file but distributed with shared_ptr,
> for people like me who really like operator->*? Maybe something
> like: "shared_ptr2member.hpp"? I realize you probably don't want to
> introduce a dependency on bind() and function<> to shared_ptr.

I'm not sure it's worth it. The above is far less-efficient than some
alternatives, both in speed and in code size. It seems like a high price to
pay for a little syntax. Wouldn't a syntax like:

    invoke(target, pmf, arg1, arg2...)

work reasonably well in place of:

    target->*pmf(arg1, arg2 ...)


That approach wouldn't intrude on shared_ptr at all.


Boost list run by bdawes at, gregod at, cpdaniel at, john at