Subject: Re: [boost] boost::mpl::for_each and value_initialized
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2010-01-21 13:20:59
>> Do I understand correctly that you want the memset call to be
>> skipped for those compiler versions that have implemented
>> value-initialization entirely correctly?
Peter Foelsche wrote:
> I'm only concerned with boost::mpl::for_each
> This function calls a function object by passing an object of the
> matching type.
> The contents of this object usually do not matter -- and in case they
> do, the programmer can write a default constructor to initialize this
> object. So there is no need in boost::mpl::for_each to call
So you think the issue can be resolved properly, merely by modifying
mpl/for_each.hpp, right? You proposed at
http://lists.boost.org/Archives/boost/2009/09/155805.php to modify
mpl/for_each.hpp by changing:
! value_initialized<arg> x;
! aux::unwrap(f, 0)(boost::get(x));
! aux::unwrap(f, 0)(arg());
I see some subtle differences here. First of all, boost::get(x) return a
reference to an lvalue, while arg() is an rvalue. Do you think that's okay?
Secondly, things *might* go wrong if arg doesn't have a user-declared
default-constructor *and* the compiler hasn't correctly implemented
value-initialization. That's why Fernando and I added the memset call to
boost::value_initialized, of course. But you think the data members of the
temporary arg() won't be accessed anyway, right? Unless arg has a
I'm sorry I don't know mpl/for_each.hpp well enough. But if the answer to
each of the above questions is yes, I guess your proposal is fine.
Kind regards, Niels
-- Niels Dekker http://www.xs4all.nl/~nd/dekkerware Scientific programmer at LKEB, Leiden University Medical Center