Boost logo

Boost Users :

From: Trent Hill (trent.hill_at_[hidden])
Date: 2004-11-16 04:11:15


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<T_Param>, 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<R,F>::type' to 'boost::_bi::bind_t<R,F,L>'
        with
        [
            T_Param=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>
        ]
        and
        [
            R=void,
            F=void (__cdecl *)(int)
        ]
        and
        [
            R=void,
            F=void (__cdecl *)(int),
            L=boost::_bi::list1<boost::_bi::list_av_1<int>::B1>
        ]
        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 ()<boost::_bi::bind_t<R,F,L>::result_type,void(__cdecl
*)(T_Param),boost::_bi::list0>(boost::_bi::type<T>,void,A &) const' being compiled
        with
        [

            R=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>::result_type,
            A1=boost::_bi::list_av_1<boost::_bi::bind_t<void,void (__cdecl
*)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>>::B1,
            F=void (__cdecl *)(int),
            L=boost::_bi::list1<boost::_bi::list_av_1<int>::B1>,
            T_Param=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>,
            T=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>::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<R,F,L>::result_type boost::_bi::bind_t<R,F,L>::operator ()(void)'
        with
        [
            R=void,
            F=void (__cdecl *)(boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>),
            L=boost::_bi::list1<boost::_bi::list_av_1<boost::_bi::bind_t<void,void (__cdecl
*)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>>::B1>
        ]
        c:/workspace\ main.cpp(36) : see reference to class template instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
        with
        [
            R=void,
            F=void (__cdecl *)(boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>),
            L=boost::_bi::list1<boost::_bi::list_av_1<boost::_bi::bind_t<void,void (__cdecl
*)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>>::B1>
        ]
        c:/workspace\ main.cpp(46) : see reference to function template instantiation 'void
callFooWith<boost::_bi::bind_t<R,F,L>>(T_Param)' being compiled
        with
        [
            R=void,
            F=void (__cdecl *)(int),
            L=boost::_bi::list1<boost::_bi::list_av_1<int>::B1>,
            T_Param=boost::_bi::bind_t<void,void (__cdecl *)(int),boost::_bi::list1<boost::_bi::list_av_1<int>::B1>>
        ]


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net