some problem with boost::bind.

The sample code is like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <boost/bind.hpp>
#include <boost/system/error_code.hpp>
#include <string>

template<typename Handler1, typename Handler2>
void two_handler_test_func(const char* p1, const char* p2, Handler1 handler1, Handler2 handler2)
{
    handler1(boost::system::error_code());
    handler2(boost::system::error_code());
}

class MyTestClass
{
public:
    template<typename Handler>
    void test_func(const std::string& p1, const std::string& p2, Handler handler)
    {
        two_handler_test_func(p1.c_str(), p2.c_str(), 
            boost::bind(&MyTestClass::handle_test_func1<Handler>, this, _1, handler),
            boost::bind(&MyTestClass::handle_test_func2, this, _1, 2));
    }

private:
    template<typename Handler>
    void handle_test_func1(const boost::system::error_code& ec, Handler handler)
    {
        handler(ec);
    }

    void handle_test_func2(const boost::system::error_code& ec, int b)
    {}

};

void command_listen_finished(const boost::system::error_code& ec, int i)
{}

void command_listen_finished2(const boost::system::error_code& ec)
{}

class TestCallback
{
public:
    TestCallback(int i)
        :m_i(i)
    {}

    void operator()(const boost::system::error_code& ec)
    {}
private:
    int m_i;
};

int main()
{
    MyTestClass testClass;
    testClass.test_func("abc", "def", boost::bind(command_listen_finished, _1, 1));
    //testClass.test_func("abc", "def", command_listen_finished2);
    //testClass.test_func("abc", "def", TestCallback(1));
    return 0;
}


The last three "testClass.test_func" call.
The first one can not pass the compile, but the second and thrid can.
I thought the first one bind is build a same functor as the third one, but it just can not pass compile.

The compile I use is VC9, the detail version is below:
Microsoft Visual Studio 2008
Version 9.0.30729.1 SP
Microsoft .NET Framework
Version 3.5 SP1
Installed Edition: Enterprise
Microsoft Visual C++ 2008 91899-153-0000007-60183

Thanks for help...
By the way, The boost version I use is boost 1.4.3
Topic archived. No new replies allowed.