|
Boost : |
From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-10-04 13:38:10
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.
(Unfortunately the iterator adaptors still contain nested bind class
templates, sigh. So bind and the iterator adaptors can't both be used on
MSVC.)
-- Peter Dimov Multi Media Ltd.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk