Boost logo

Boost Users :

Subject: [Boost-users] boost::bind can't bind bind_t type right?
From: ???? (fireemissary_at_[hidden])
Date: 2011-03-15 09:37:42


#include <iostream>
#include <boost/bind.hpp>
#include <boost/function.hpp>

class test1
{
public:
    template<typename S>
    double handle(S s)
    {
        s(1);
        std::cout<<"test1\n";
        return 1;
    }
    template<typename F>
    void handle1(F f){
    
         boost::bind(&test1::handle<F>,this,f)();
      
    }

};
class test2
{
public:
    double handle(int i)
    {
        std::cout<<"test2\n";
        return i;
    }
};
int _tmain(int argc, _TCHAR* argv[])
{
    test2 t2;
    test1 t1;
    t1.handle1(boost::bind(&test2::handle,t2,_1));
    return 0;
}

in test1::handle1 complie fail on vs2010 and gcc 4.4.1
vs 2010 error:error C2664: "R boost::_mfi::mf1<R,T,A1>::operator ()<test1>(const U &,A1) const": can't convert "double"to "boost::_bi::bind_t<R,F,L>" .
but boost::bind(&test1::handle<F>,this,f)(); f is not double,f is bind_t and double only return_type.

by the way,boost::bind(&test1::handle<F>,this,boost::ref(f))(); can work.
                  



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