Call of member function using bind like functionallity
<p>How to implement a very simple edition of boost::bind, which does not bind arguments, but offer a way to call member function in c++ classes.</p>

<p>Here is my first try:</p>

<pre><code>#include &lt;iostream&gt;

struct Foo {
    void x(int i) { std::cout &lt;&lt; "Foo " &lt;&lt; i &lt;&lt; std::endl; }
};

struct Bar {
    void y(int i) { std::cout &lt;&lt; "Bar " &lt;&lt; i &lt;&lt; std::endl; }
};

template&lt;typename A1, typename I, typename M&gt;
struct Binder {
    Binder(I i, M m) : i_(i), m_(m) { }
    void operator()(A1 a1) {
        (i_-&gt;*m_)(a1);
    }

    I i_;
    M m_;
};

template&lt;typename A1, typename I, typename M&gt;
Binder&lt;A1, I, M&gt; my_bind(I i, M m) {
    return Binder&lt;A1, I, M&gt;(i, m);
}

int main(int argc, const char *argv[])
{
    Foo foo;
    Bar bar;

    Binder&lt;int, Foo*, void (Foo::*)(int)&gt; b1 = my_bind&lt;int&gt;(&amp;foo, &amp;Foo::x);
    Binder&lt;int, Bar*, void (Bar::*)(int)&gt; b2 = my_bind&lt;int&gt;(&amp;bar, &amp;Bar::y);

    b1(1);
    b2(2);

    return 0;
}
</code></pre>

<p>The implementation above does work, and will print:</p>

<pre><code>Foo 1
Bar 2
</code></pre>

<p>The problem is that the two invokes of my_bind returns objects of different types. How can I alter the program, such that my_bind will return a type which only depends on A1.</p>
