|
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
(http://boost.org/libs/bind/bind.html):
---8<---
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);
---8<---
-- Caleb Epstein caleb dot epstein at gmail dot com
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net