[boost] bind + lambda example fails on msvc2003
by Craigp other posts by this author
Aug 25 2003 5:27AM messages near this date
[boost] Re: memcpy_copyable<> and memcpy_moveable<> type traits
|
[boost] [bgl] traits question
I tried the following example (taken from
http://boost.org/libs/lambda/doc/ar01s05.html#sect:construction_and_destruction) ,
and it failed to compile:
std::vector<int> x(10);
std::vector<int> y(10);
std::vector<std::pair<int, int> > pairs;
std::transform(x.begin(), x.end(), y.begin(), std::back_inserter(pairs),
boost::bind(boost::lambda::constructor<std::pair<int, int> >(), _1,
_2));
Compiling...
main.cpp
c:\dev\boost-1.30.2\boost\bind.hpp(60) : error C2039: 'result_type' : is not
a member of 'boost::lambda::constructor<T> '
with
[
T=std::pair<int,int>
]
c:\dev\boost-1.30.2\boost\bind\bind_template.hpp(16) : see reference
to class template instantiation 'boost::_bi::result_traits<R,F> ' being
compiled
with
[
R=boost::_bi::unspecified,
F=boost::lambda::constructor<std::pair<int,int> >
]
c:\dev\projects\boost\main.cpp(67) : see reference to class template
instantiation 'boost::_bi::bind_t<R,F,L> ' being compiled
with
[
R=boost::_bi::unspecified,
F=boost::lambda::constructor<std::pair<int,int> >,
L=boost::_bi::list2<boost::_bi::list_av_2<boost::arg<1> ,boost::arg<2>>::B1,b
oost::_bi::list_av_2<boost::arg<1> ,boost::arg<2>>::B2>
]
c:\dev\boost-1.30.2\boost\bind.hpp(60) : error C2146: syntax error : missing
';' before identifier 'type'
c:\dev\boost-1.30.2\boost\bind.hpp(60) : error C2955: 'boost::_bi::type' :
use of class template requires template argument list
c:\dev\boost-1.30.2\boost\bind.hpp(92) : see declaration of
'boost::_bi::type'
c:\dev\boost-1.30.2\boost\bind.hpp(60) : fatal error C1903: unable to
recover from previous error(s); stopping compilation
----
In boost/lambda/construct.hpp, I added the following line, and it worked:
template<class T> struct constructor {
template <class U> struct sig { typedef T type; };
+ typedef T result_type;
T operator()() const {
return T();
}
...
HTH,
--craig
_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
|