 <p><a href="http://www.boost.org/doc/libs/1_39_0/doc/html/boost/reference_wrapper.html" rel="nofollow noreferrer"><code>boost::reference_wrapper</code></a> (which is what <code>boost::ref</code> returns) does not overload <code>operator()</code>. You can use it with <code>boost::bind</code>, which has special treating for it (not using <code>ref</code> would make <code>bind</code> copy the provided function object). </p> <p>But <code>for_each</code> returns the function object it invokes the stuff on. So just do this</p> <pre><code>between_1_and_10 val; val.d = 4; val = for_each(lst.begin(), lst.end(), val); printf("rg"); </code></pre> <p>It will call the stuff on the copied <code>val</code>, and return the function object as it's after the last invocation. </p> <hr> <p>Just to tell you where you might use <code>boost::ref</code>, because you seem to misuse it. Imagine a template that takes its parameter by value, and calls another function:</p> <pre><code>void g(int &amp;i) { i++; } template&lt;typename T&gt; void run_g(T t) { g(t); } </code></pre> <p>If you now want to call it with a variable, it will copy it. Often, that's a reasonable decision, for example if you want to pass data to a thread as start parameters, you could copy it out of your local function into the thread object. But sometimes, you could want not to copy it, but to actually pass a reference. This is where <code>boost::reference_wrapper</code> helps. The following actually does what we expect, and outputs <code>1</code>:</p> <pre><code>int main() { int n = 0; run_g(boost::ref(n)); std::cout &lt;&lt; n &lt;&lt; std::endl; } </code></pre> <p>For binding arguments, a copy is a good default. It also easily makes arrays and functions decay to pointers (accepting by reference would make <code>T</code> be possibly an array/function-type, and would cause some nasty problems). </p>