Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2002-07-25 09:52:35


From: "Daniel Frey" <daniel.frey_at_[hidden]>
> Peter Dimov wrote:
> >
> > The bind equivalent to less_element is
> >
> > bind(less<std::string>(), bind(&person::firstname, _1),
> > bind(&person::firstname, _1))
> >
> > which is sufficiently complex to be impractical.
> >
> > You could make a helper
> >
> > template<template<class> class Comparator, class R, class T>
> > {insert return type here} element(R T::* pm)
> > {
> > return bind(Comparator<R>(), bind(pm, _1), bind(pm, _1));
> > }
> >
> > where the return type is something incomprehensible (where's typeof when
we
> > need it?).
>
> Can't we assume it's a binary function and use 'Comparator< R
> >::result_type'?

Oh yes, but I was talking about element's return type. Which is

boost::_bi::bind_t<boost::_bi::unspecified, Comparator<R>,
boost::_bi::list2<boost::_bi::bind_t<R, boost::_mfi::dm<R, T>,
boost::_bi::list1<boost::arg<1> > >, boost::_bi::bind_t<R,
boost::_mfi::dm<R, T>, boost::_bi::list1<boost::arg<1> > > > >

:-)

That aside, most compilers frown at

element<std::less>(&person::firstname)

anyway. Bleeding edge business.

element(std::less<std::string>(), &person::firstname)

is the syntax that has a chance to work.


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