Boost logo

Boost :

From: Levente Farkas (lfarkas_at_[hidden])
Date: 2001-10-05 05:05:38


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.
>
> (Unfortunately the iterator adaptors still contain nested bind class
> templates, sigh. So bind and the iterator adaptors can't both be used on
> MSVC.)

I donwload Jeremy's new iterator_adaptors.hpp and David new
named_template_params.hpp, but the above example with your changes still
not compile! I listed the error on MSVC and with gcc.
MSVC:
-------------------------------------------------
c:\INCLUDE\boost/iterator_adaptors.hpp(628) : error C2529: '<Unknown>' :
reference to reference is illegal
        C:\PROJECTS\LIB\Speech\test\proj.cpp(52) : see reference to template
instantiation
'boost::iterator_adaptor<iter,boost::projection_iterator_policies<boost::_bi::bind_t<double
&,VectorAccess<vector<double>>,boost::_bi::list1<boost::_bi::bind_
t<vector<double>
&,MemberAccess<A,vector<double>>,boost::_bi::list1<boost::_bi::arg<1>>>>>>,double
&,double * &,double
**,boost::detail::default_argument,boost::detail::default_argument>' being
compiled
c:\INCLUDE\boost/iterator_adaptors.hpp(628) : warning C4181: qualifier applied
to reference type ignored
        C:\PROJECTS\LIB\Speech\test\proj.cpp(52) : see reference to template
instantiation
'boost::iterator_adaptor<iter,boost::projection_iterator_policies<boost::_bi::bind_t<double
&,VectorAccess<vector<double>>,boost::_bi::list1<boost::_bi::bind_
t<vector<double>
&,MemberAccess<A,vector<double>>,boost::_bi::list1<boost::_bi::arg<1>>>>>>,double
&,double * &,double
**,boost::detail::default_argument,boost::detail::default_argument>' being
compiled
c:\INCLUDE\boost/iterator_adaptors.hpp(628) : error C2529: '<Unknown>' :
reference to reference is illegal
        C:\PROJECTS\LIB\Speech\test\proj.cpp(52) : see reference to template
instantiation
'boost::iterator_adaptor<iter,boost::projection_iterator_policies<boost::_bi::bind_t<double
&,VectorAccess<vector<double>>,boost::_bi::list1<boost::_bi::bind_
t<vector<double>
&,MemberAccess<A,vector<double>>,boost::_bi::list1<boost::_bi::arg<1>>>>>>,double
&,double * &,double
**,boost::detail::default_argument,boost::detail::default_argument>' being
compiled

with gcc:
-------------------------------------------------
../boost_1_25_0/boost/iterator_adaptors.hpp: In instantiation of `boost::const_p
rojection_iterator_generator<boost::_bi::bind_t<double &, VectorAccess<_STL::vec
tor<double, _STL::allocator<double> > >, boost::_bi::list1<boost::_bi::bind_t<_S
TL::vector<double, _STL::allocator<double> > &, MemberAccess<A, _STL::vector<dou
ble, _STL::allocator<double> > >, boost::_bi::list1<boost::_bi::arg<1> > > > >,
_STL::_List_iterator<A, _STL::_Nonconst_traits<A> > >':
proj.cpp:52: instantiated from here
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: forming reference to reference
 type `double &const'
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 1 is invalid
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 1 is invalid
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 1 is invalid
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 4 is invalid
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 5 is invalid
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 6 is invalid
../boost_1_25_0/boost/iterator_adaptors.hpp:1068: template argument 7 is invalid
proj.cpp: In function `int main ()':
proj.cpp:52: no matching function for call to
`make_const_projection_iterator (_STL::_List_iterator<A,
_STL::_Nonconst_traits<A> >, boost::_bi::bind_t<double &,
VectorAccess<_STL::vector<double, _STL::allocator<double> > >,
boost::_bi::list1<boost::_bi::bind_t<_STL::vector<double,
_STL::allocator<double> > &, MemberAccess<A, _STL::vector<double,
_STL::allocator<double> > >, boost::_bi::list1<boost::_bi::arg<1> > > >
>)'
proj.cpp:55: no matching function for call to
`make_const_projection_iterator (_STL::_List_iterator<A,
_STL::_Nonconst_traits<A> >, boost::_bi::bind_t<double &,
VectorAccess<_STL::vector<double, _STL::allocator<double> > >,
boost::_bi::list1<boost::_bi::bind_t<_STL::vector<double,
_STL::allocator<double> > &, MemberAccess<A, _STL::vector<double,
_STL::allocator<double> > >, boost::_bi::list1<boost::_bi::arg<1> > > >
>)'

 -- 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