mpl for_each copies function object (bug?)
Hi there!
I'm currently struggling with mpl::for_each: It copies my
function object no matter what I do. Here is some dummy code:
worker_t workit; // the worker object which recieves the
different types and has an internal state
mpl::for_each< mpl::vector
Hi, Sebastia!
Please use boost::reference_wrapper to disable copying...
mpl::for_each< mpl::vector
Hi there!
I'm currently struggling with mpl::for_each: It copies my function object no matter what I do. Here is some dummy code:
worker_t workit; // the worker object which recieves the different types and has an internal state
mpl::for_each< mpl::vector
, worker_t& >(workit); Now, the workit object becomes copied which is clear from the sources. However, I explicitly requested it not to be copied by the hint of giving the reference worker_t& as a template parameter.
Maybe this behaviour is wanted, but I do not see the reason. In the fusion-world this is the way to go if one wants to prevent copying of function objects.
Is this now a bug or a feature and how can I fix it (quick).
Greetings,
Sebastian
Hi Ovanes! Ahh, sure you are right. I got too much used to fusion notion which I think is superior in this point. But I guess there are some reasons for the ref-wrapping stuff which works. Thanks again. Sebastian Ovanes Markarian schrieb:
Hi, Sebastia!
Please use boost::reference_wrapper to disable copying...
mpl::for_each< mpl::vector
, worker_t& >(boost::ref(workit)); Hope that helps.
Ovanes
On Tue, May 20, 2008 at 8:35 AM, Sebastian Weber
mailto:sebastian.weber@physik.tu-darmstadt.de> wrote: Hi there!
I'm currently struggling with mpl::for_each: It copies my function object no matter what I do. Here is some dummy code:
worker_t workit; // the worker object which recieves the different types and has an internal state
mpl::for_each< mpl::vector
, worker_t& >(workit); Now, the workit object becomes copied which is clear from the sources. However, I explicitly requested it not to be copied by the hint of giving the reference worker_t& as a template parameter.
Maybe this behaviour is wanted, but I do not see the reason. In the fusion-world this is the way to go if one wants to prevent copying of function objects.
Is this now a bug or a feature and how can I fix it (quick).
Greetings,
Sebastian
------------------------------------------------------------------------
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Ovanes Markarian
-
Sebastian Weber