Hi all,
I'm running into a compile error using bind with visual c++ 7.1 and am hoping
some clever cookie here will be able to help. I've whittled the issue down to
a few simple functions (you'll have to trust that it makes sense in the original
context):
template <typename T_Param>
void foo(T_Param a_param)
{
}
template <typename T_Param>
void callFooWith(T_Param a_param)
{
boost::bind(&foo, a_param)(); // <- (1) ERROR HERE
}
void bar(int)
{
}
int main(int a_argc, char *a_argv[])
{
callFooWith(42); // <- (2) FINE
callFooWith(boost::bind(&bar, 10)); // <- (3) FAILS
return 0;
}
If I remove line (3), it compiles without error. Adding line (3) results in
a compile error reported at line (1) (error is at bottom of post). The compile
error seems to stem from operator() on line (1); if the "()" is removed from
line (1), the code will compile without error.
Any ideas?
Thanks a bunch,
Trent.
*** Error message follows ***
c:/workspace\swlib2\BOOST\1.30.2\win32\files\boost\bind.hpp(186) : error C2664: 'void (T_Param)' : cannot convert parameter 1 from
'boost::_bi::result_traits::type' to 'boost::_bi::bind_t'
with
[
T_Param=boost::_bi::bind_t>
]
and
[
R=void,
F=void (__cdecl *)(int)
]
and
[
R=void,
F=void (__cdecl *)(int),
L=boost::_bi::list1
]
Expressions of type void cannot be converted to other types
c:/workspace\swlib2\BOOST\1.30.2\win32\files\boost\bind\bind_template.hpp(21) : see reference to function template
instantiation 'R boost::_bi::list1<A1>::operator ()::result_type,void(__cdecl
*)(T_Param),boost::_bi::list0>(boost::_bi::type<T>,void,A &) const' being compiled
with
[
R=boost::_bi::bind_t>::result_type,
A1=boost::_bi::list_av_1>>::B1,
F=void (__cdecl *)(int),
L=boost::_bi::list1,
T_Param=boost::_bi::bind_t>,
T=boost::_bi::bind_t>::result_type,
A=boost::_bi::list0
]
c:/workspace\swlib2\BOOST\1.30.2\win32\files\boost\bind\bind_template.hpp(19) : while compiling class-template member
function 'boost::_bi::bind_t::result_type boost::_bi::bind_t::operator ()(void)'
with
[
R=void,
F=void (__cdecl *)(boost::_bi::bind_t>),
L=boost::_bi::list1>>::B1>
]
c:/workspace\ main.cpp(36) : see reference to class template instantiation 'boost::_bi::bind_t' being compiled
with
[
R=void,
F=void (__cdecl *)(boost::_bi::bind_t>),
L=boost::_bi::list1>>::B1>
]
c:/workspace\ main.cpp(46) : see reference to function template instantiation 'void
callFooWith>(T_Param)' being compiled
with
[
R=void,
F=void (__cdecl *)(int),
L=boost::_bi::list1,
T_Param=boost::_bi::bind_t>
]