Subject: Re: [boost] boost::mpl::for_each and value_initialized
From: Domagoj Saric (domagoj.saric_at_[hidden])
Date: 2009-09-02 05:11:12
"Peter Foelsche" <peter_foelsche_at_[hidden]> wrote in message
> 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?
i second that...
...msvc++ 8.0 and 9.0 ("with all available optimizations and maximum
inlining depth") are also "unable" to remove the redundant memset() call (it
is only sometimes replaced with an intrinsic implementation)...
there was a somewhat related discussion (
http://lists.boost.org/Archives/boost/2004/02/61582.php ) dealing, among
other things, with the problem of default construction in mpl::for_each ...
in the current implementation you must either pay for default construction
or pay for added verbosity/ugliness of the "wrap" approach...
...i must admit i did not quite understand the argument of Aleksey Gurtovoy
that the proposed "aux::unwrap(f, 0)::operator()<arg>()" solution would
"would rule out ordinary function objects" (can you even use them with
mpl::for_each?) and that "it's not portable" (the ::operator()<arg>() syntax
is not standard?)...
(apologies if this should go to a seperate thread...it seemed related enough
-- "That men do not learn very much from the lessons of history is the most important of all the lessons of history." Aldous Huxley