Is this std::ref behaviour logical? : <p>Consider this code:</p>

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

int xx = 7;

template&lt;class T&gt;
void f1(T arg)
{
    arg += xx;
}

template&lt;class T&gt;
void f2(T arg)
{
    arg = xx;
}

int main()
{
    int j;

    j=100;
    f1(std::ref(j));
    std::cout &lt;&lt; j &lt;&lt; std::endl;

    j=100;
    f2(std::ref(j));
    std::cout &lt;&lt; j &lt;&lt; std::endl;
}
</code></pre>

<p>When executed, this code outputs</p>

<pre><code>107
100
</code></pre>

<p>I would have expected the second value to be 7 rather than 100.</p>

<p>What am I missing?</p>
