[function] Automatic boost::ref for functors?

Hi,
I noticed in the Boost.Function documentation here that it explains how to
pass a reference to a function object into a boost::function. Is there a way
to make boost::function automatically take the reference of any function
object it is given? For example:
boost::function

AMDG Robert Dailey wrote:
I noticed in the Boost.Function documentation here that it explains how to pass a reference to a function object into a boost::function. Is there a way to make boost::function automatically take the reference of any function object it is given? For example:
boost::function
f; f = MyFunctionObject(); // This is an implicit: f = boost::cref( MyFunctionObject() );
Wouldn't that create a dangling reference? In Christ, Steven Watanabe

On Wed, Nov 12, 2008 at 2:56 PM, Steven Watanabe
AMDG
Robert Dailey wrote:
I noticed in the Boost.Function documentation here that it explains how to pass a reference to a function object into a boost::function. Is there a way to make boost::function automatically take the reference of any function object it is given? For example:
boost::function
f; f = MyFunctionObject(); // This is an implicit: f = boost::cref( MyFunctionObject() ); Wouldn't that create a dangling reference?
Crap, good point. I got ahead of myself :) Never mind! Thanks for the help, though.
participants (2)
-
Robert Dailey
-
Steven Watanabe