|
Boost Users : |
From: Marc VIALA (mviala_at_[hidden])
Date: 2006-01-23 14:03:22
Thanks for your help, but...
boost::function<void (void)> pg = boost::bind((void(X::*)(int,int))&X::g,
&x, a, b) ;
Oups, with the correction same result, compilation failed, but not with the
same first message error: " can't convert 'overloaded-function' in 'void
(__thiscall X::* )(int,int)' " now?
Could you give some feedbacks about the reason of the compilation failure?
Is this due to some restrictions on VC++ 7.1?
Thanks in advance.
Best regards,
Marc Viala
mailto:mviala_at_[hidden]
-----Message d'origine-----
De : boost-users-bounces_at_[hidden]
[mailto:boost-users-bounces_at_[hidden]] De la part de Rene Rivera
Envoyé : lundi 23 janvier 2006 17:12
À : boost-users_at_[hidden]
Objet : Re: [Boost-users] [Boost][Bind] How to bind template function member
Marc Viala wrote:
> Hi,
>
> I would like to know how I can use boost::bind with template function
> member?
>
> To explain my problem, you will find hereafter an example code that
> demonstrates it. In this code, when we try to bind the function member
> X::g the compiler failed with tons of error message.
>
> Am I doing something wrong?
>
> Best regards,
>
> Marc Viala
> mailto:mviala_at_[hidden]
>
> -----------------------------------
> Platform:
> VC++ 7.1
> Boost 1.33.1
>
> -----------------------------------
> #include <boost/bind.hpp>
> #include <boost/function.hpp>
>
> struct X {
> template<typename A, typename B>
> void g(A& a, B& b)
> { std::cout << a << " " << b << '\n' ; }
>
> void
> f(int& i)
> { std::cout << i << '\n'; }
> } ;
>
> template<typename A, typename B>
> void e(A& a, B& b)
> { std::cout << a << " " << b << '\n' ; }
>
> int
> main(int argc, char* argv[])
> {
> int a = 10, b = 11 ;
> X x ;
> boost::function<void (void)> pe = boost::bind(&e<int,int>, a, b) ;
> // <- OK
> pe() ;
> boost::function<void (void)> pg = boost::bind(&X::g<int,int>, &x, a,
> b) ; // <- Don't compile?
Try... = boost::bind((void(X::*)(int,int))&X::g,&x,a,b)
-- -- Grafik - Don't Assume Anything -- Redshift Software, Inc. - http://redshift-software.com -- rrivera/acm.org - grafik/redshift-software.com -- 102708583/icq - grafikrobot/aim - Grafik/jabber.org _______________________________________________ Boost-users mailing list Boost-users_at_[hidden] http://lists.boost.org/mailman/listinfo.cgi/boost-users
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