
Having written code using a stateful functor with mpl::for_each and observing that side effects were not taking place, I went to http://www.boost.org/libs/mpl/doc/refmanual/refmanual_toc.html to confirm my suspicion that the functor was being passed by value. But there appears to be no documentation for mpl::for_each (neither in the HTML version of the reference manual nor in the PDF version). I ultimately confirmed my suspicion by looking at the header file, but is there a reason why for_each seems to be documented only in the printed book? Thanks, Scott

Scott, Scott Meyers writes:
Having written code using a stateful functor with mpl::for_each and observing that side effects were not taking place, I went to http://www.boost.org/libs/mpl/doc/refmanual/refmanual_toc.html to confirm my suspicion that the functor was being passed by value. But there appears to be no documentation for mpl::for_each (neither in the HTML version of the reference manual nor in the PDF version). I ultimately confirmed my suspicion by looking at the header file, but is there a reason why for_each seems to be documented only in the printed book?
It was (accidentally) missed out. It's fixed in 1.34 release; meanwhile, the page can be accessed online at http://tinyurl.com/2f3zvv (http://boost.cvs.sourceforge.net/*checkout*/boost/boost/libs/mpl/doc/refmanual/for-each.html?revision=1.1.2.1&pathrev=RC_1_34_0) HTH, -- Aleksey Gurtovoy MetaCommunications Engineering

Dear fellow boost users, I'd like to address a problem I just encountered on using mpl::for_each (Boost 1.33). Similar to Scott, I implemented a stateful functor that should be called for all types in a mpl::vector<>. for_each is no option, since it passes the functor by value (Maybe someone could enlighten me in stating why this is a wanted behaviour? According to the meta-programming book, for_each takes a functor to be able to store the results of a computation which is not possible if the functor is copied?). Are there any alternatives to for_each for that case? Regards Hendrik -----Ursprüngliche Nachricht----- Von: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] Im Auftrag von Aleksey Gurtovoy Gesendet: Donnerstag, 29. März 2007 11:48 An: boost-users@lists.boost.org Cc: dave@boost-consulting.com; Scott Meyers Betreff: Re: [Boost-users] [mpl] Doc for for_each Scott, Scott Meyers writes:
Having written code using a stateful functor with mpl::for_each and observing that side effects were not taking place, I went to http://www.boost.org/libs/mpl/doc/refmanual/refmanual_toc.html to confirm my suspicion that the functor was being passed by value. But there appears to be no documentation for mpl::for_each (neither in the HTML version of the reference manual nor in the PDF version). I ultimately confirmed my suspicion by looking at the header file, but is there a reason why for_each seems to be documented only in the printed book?
It was (accidentally) missed out. It's fixed in 1.34 release; meanwhile, the page can be accessed online at http://tinyurl.com/2f3zvv (http://boost.cvs.sourceforge.net/*checkout*/boost/boost/libs/mpl/doc/refman ual/for-each.html?revision=1.1.2.1&pathrev=RC_1_34_0) HTH, -- Aleksey Gurtovoy MetaCommunications Engineering _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users

Hendrik Belitz wrote:
I'd like to address a problem I just encountered on using mpl::for_each (Boost 1.33). Similar to Scott, I implemented a stateful functor that should be called for all types in a mpl::vector<>. for_each is no option, since it passes the functor by value
I slapped a boost::ref around the functor, and that worked fine for me. I suggest you try the same thing and see if that works for you. Scott

Thanks, that approach works perfectly for me, too. Hendrik Scott Meyers wrote:
I slapped a boost::ref around the functor, and that worked fine for me. I
suggest you try the same thing and see if that works for you.
Scott
participants (3)
-
Aleksey Gurtovoy
-
Hendrik Belitz
-
Scott Meyers