
15 Jul
2012
15 Jul
'12
12:31 p.m.
Le Sun, 15 Jul 2012 13:37:06 +0200, Klaim - Joël Lamotte <mjklaim@gmail.com> a écrit :
I see.
Did you consider copying the value instead of keeping a reference to it? Also, what do you think about allowing the user to use one or the other?
Sorry I made a mistake in the code that results in a misunderstanding. The argument of the function g() should not be a reference: void g( boost::function<double (double)> func ) { double t = /* … */; double d = func( t ); // … } int main() { g( &f ); } Thus, it is a copy of the function object. There is no reason to keep a reference to the boost::function here. Julien Jorge