Boost logo

Boost :

Subject: Re: [boost] boost::mpl::for_each and value_initialized
From: Aleksey Gurtovoy (agurtovoy_at_[hidden])
Date: 2010-01-22 02:20:15


On Thu, 21 Jan 2010 12:20:59 -0600, Niels Dekker - address until
2010-10-10 <niels_address_until_2010-10-10_at_[hidden]> wrote:
> 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
>> value_initialized.
>
> 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));
>
> Into:
>
> ! 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.

It would also break for_each iteration over a sequence of array types,
although admittedly that one is likely to be written as

    mpl::for_each< array_types,mpl::make_identity<mpl::_1> >( ... );

Hmm, may be I should just go forward with the patch.

-- 
Aleksey Gurtovoy
MetaCommunications Engineering

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