Boost logo

Boost :

Subject: [boost] boost::mpl::for_each and value_initialized
From: Peter Foelsche (peter_foelsche_at_[hidden])
Date: 2009-09-01 16:10:17


Dear All,

what is the use of value_initialized in boost::mpl::for_each?
It should be sufficient if the value is initialized by the constructor.
value_initialized() calls memset() in before calling the constructor.
This memset() is not being optimized away with gnu-c++ 4.4.1.
What class does require zeroed memory to work correctly?

Peter

*** boost_1_40_0/boost/mpl/for_each.hpp Mon Aug 17 22:16:53 2009
--- boost_1_40_0.saved/boost/mpl/for_each.hpp Tue Sep 1 12:54:55 2009
***************
*** 71,78 ****
      
          // dwa 2002/9/10 -- make sure not to invoke undefined behavior
          // when we pass arg.
! value_initialized<arg> x;
! aux::unwrap(f, 0)(boost::get(x));
          
          typedef typename mpl::next<Iterator>::type iter;
          for_each_impl<boost::is_same<iter,LastIterator>::value>
--- 71,78 ----
      
          // dwa 2002/9/10 -- make sure not to invoke undefined behavior
          // when we pass arg.
! //value_initialized<arg> x;
! aux::unwrap(f, 0)(arg());
          
          typedef typename mpl::next<Iterator>::type iter;
          for_each_impl<boost::is_same<iter,LastIterator>::value>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk