|
Boost : |
From: Alexey Nikitin (reductor_at_[hidden])
Date: 2004-01-30 12:26:59
I try to compile next code:
===== my_test.cpp =====
#include <functional>
#include <boost/bind.hpp>
using namespace std;
using namespace boost;
struct my_assign_if
{
typedef void result_type;
template<class T, class P>
void operator()(T& dst, T const& src, P const& to_assign) const { if
(to_assign()) dst = src; }
};
int main()
{
int a=1, b=0;
bind(my_assign_if(), ref(a), 0, _1)(bind(less<int>(), cref(b), 1)); //
compiled
bind(my_assign_if(), ref(a), 0, bind(less<int>(), cref(b), 1))(); // not
compiled
return 0;
}
====================
and take next errors:
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.
my_test.cpp
my_test.cpp(11) : error C2064: term does not evaluate to a function taking 0
arguments
C:\Alnik\heap\boost\boost-dev\boost\bind.hpp(335) : see reference to
function template instantiation 'void my_assign_if::operator
()<T,boost::_bi::result_traits<R,F>::type>(T &,const T &,const P &) const'
being compiled
with
[
T=int,
R=boost::_bi::unspecified,
F=std::less<int>,
P=boost::_bi::result_traits<boost::_bi::unspecified,std::less<int>>::type
]
C:\Alnik\heap\boost\boost-dev\boost\bind\bind_template.hpp(21) : see
reference to function template instantiation 'R
boost::_bi::list3<A1,A2,A3>::operator
()<boost::_bi::bind_t<boost::_bi::unspecified,F,L>::result_type,F,boost::_bi
::list0>(boost::_bi::type<T>,F,A &)' being compiled
with
[
R=boost::_bi::bind_t<boost::_bi::unspecified,my_assign_if,boost::_bi::list3<
boost::_bi::list_av_3<boost::reference_wrapper<int>,int,boost::_bi::bind_t<b
oost::_bi::unspecified,std::less<int>,boost::_bi::list2<boost::_bi::list_av_
2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B1,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B2,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B3>>::result_type,
A1=boost::_bi::list_av_3<boost::reference_wrapper<int>,int,boost::_bi::bind_
t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2<boost::_bi::list_
av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B1,
A2=boost::_bi::list_av_3<boost::reference_wrapper<int>,int,boost::_bi::bind_
t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2<boost::_bi::list_
av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B2,
A3=boost::_bi::list_av_3<boost::reference_wrapper<int>,int,boost::_bi::bind_
t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2<boost::_bi::list_
av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B3,
F=my_assign_if,
L=boost::_bi::list3<boost::_bi::list_av_3<boost::reference_wrapper<int>,int,
boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2<
boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B1,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B2,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B3>,
T=boost::_bi::bind_t<boost::_bi::unspecified,my_assign_if,boost::_bi::list3<
boost::_bi::list_av_3<boost::reference_wrapper<int>,int,boost::_bi::bind_t<b
oost::_bi::unspecified,std::less<int>,boost::_bi::list2<boost::_bi::list_av_
2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B1,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B2,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B3>>::result_type,
A=boost::_bi::list0
]
C:\Alnik\heap\boost\boost-dev\boost\bind\bind_template.hpp(19) :
while compiling class-template member function
'boost::_bi::bind_t<R,F,L>::result_type boost::_bi::bind_t<R,F,L>::operator
()(void)'
with
[
R=boost::_bi::unspecified,
F=my_assign_if,
L=boost::_bi::list3<boost::_bi::list_av_3<boost::reference_wrapper<int>,int,
boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2<
boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B1,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B2,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B3>
]
my_test.cpp(18) : see reference to class template instantiation
'boost::_bi::bind_t<R,F,L>' being compiled
with
[
R=boost::_bi::unspecified,
F=my_assign_if,
L=boost::_bi::list3<boost::_bi::list_av_3<boost::reference_wrapper<int>,int,
boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2<
boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B1,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B2,boost::_bi::list_av_3<boost::reference_wrapper<int>,int
,boost::_bi::bind_t<boost::_bi::unspecified,std::less<int>,boost::_bi::list2
<boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B1,boost::_bi::list_av_2<boost::reference_wrapper<const
int>,int>::B2>>>::B3>
]
My question: why? or that can not be used by this way?
Regards, Alexey.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk