Boost logo

Boost Users :

From: Caleb Epstein (caleb.epstein_at_[hidden])
Date: 2005-01-05 08:28:42

On Wed, 05 Jan 2005 14:11:19 +1100, Trent Hill
<trent.hill_at_[hidden]> wrote:
> I was recently surprised to find that boost::bind seems to copy
> arguments a number of times when called. For example, this program:

Use boost::ref or boost::cref. From the docs

a copy of the value of i is stored into the function object.
boost::ref and boost::cref can be used to make the function object
store a reference to an object, rather than a copy:

int i = 5;

bind(f, ref(i), _1);

Caleb Epstein
caleb dot epstein at gmail dot com

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at