Boost logo

Boost :

From: Levente Farkas (lfarkas_at_[hidden])
Date: 2001-10-04 13:48:14


Peter Dimov wrote:
>
> From: "Levente Farkas" <lfarkas_at_[hidden]>
> > there is a functional.hpp which enhanced function object adaptors, but
> > it doesn't contain the sgi's extensions like unary_compose, compose1...
> > on the other hand compose.hpp doesn't use call_traits so there can be
> > "references to references" problem same as with the original functional
> > and sgi's implementation. the same problem occur with bind.hpp.
> > the possible solutions:
> > std::compose1(f, g)
> > boost::compose_f_gx(f, g)
> > boost::bind(f, boost::bind(g, _1))
> > Lambda Library is not usable on MSVC:-(
>
> I'm not sure what your problem really is.
>
> boost::bind defines result_type as the exact return type of its operator();
> when I modify your example to use it:
>
> std::copy(
> boost::make_const_projection_iterator(a.begin(),
> boost::bind<double &>(VectorAccess<std::vector<double> >(0),
> boost::bind<std::vector<double> &>(MemberAccess<A, std::vector<double>
> >(&A::y), _1))),
> boost::make_const_projection_iterator(a.end(),
> boost::bind<double &>(VectorAccess<std::vector<double> >(0),
> boost::bind<std::vector<double> &>(MemberAccess<A, std::vector<double>
> >(&A::y), _1))),
> v.begin());
>
> I get a reference to reference error within the iterator adaptors library,
> so any changes to functional.hpp and/or compose.hpp are unlikely to fix
> that.

that's the problem! so we need a common desing strategy. is argument_type
realy the argumnet's type (without any more qualifier) and result_type
the result type or not! the basic of the whole problem is in the C++
standard which defines functors to return with value instead of reference.
so I don't know the solution:-(((
 
> (Unfortunately the iterator adaptors still contain nested bind class
> templates, sigh. So bind and the iterator adaptors can't both be used on
> MSVC.)

 -- Levente "Si vis pacem para bellum!"


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