How std::bind works with member functions
<p>I'm working with <code>std::bind</code> but I still don't get how it works when we use it with member class functions.</p>

<p>If we have the following function:</p>

<pre><code>double my_divide (double x, double y) {return x/y;}
</code></pre>

<p>I understand perfectly well the next lines of code:</p>

<pre><code>auto fn_half = std::bind (my_divide,_1,2);               // returns x/2

std::cout &lt;&lt; fn_half(10) &lt;&lt; '\n';                        // 5
</code></pre>

<p>But now, with the following code where we have a bind to member function I have some questions.</p>

<pre><code>struct Foo {
    void print_sum(int n1, int n2)
    {
        std::cout &lt;&lt; n1+n2 &lt;&lt; '\n';
    }
    int data = 10;
};

Foo foo;

auto f = std::bind(&amp;Foo::print_sum, &amp;foo, 95, _1);
f(5);
</code></pre>

<ul>
<li><p>Why is the first argument a reference? I'd like to get a theoretical explanation.</p></li>
<li><p>The second argument is a reference to the object and it's for me the most complicated part to understand. I think it's because <code>std::bind</code> needs a context, am I right? Is always like this? Has <code>std::bind</code> some sort of implementation to require a reference when the first argument is a member function?</p></li>
</ul>