Boost logo

Boost :

Subject: Re: [boost] [utility/value_init] boost::value_initialized<T> direct-initialized?
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2010-03-30 16:50:13


Niels Dekker - address until 2010-10-10 wrote:
> Can anybody please have a look at the following feature request by
> Edward Diener? https://svn.boost.org/trac/boost/ticket/3472 He proposed
> to add an explicit constructor, value_initialized(T const&), to
> boost::value_initialized<T>. This constructor would copy the value of
> its argument to the object held by value_initialized<T>.
>
> When such a constructor would be added, an object held by
> value_initialized<T> might no longer be value-initialized. Instead it
> might be direct-initialized. Does anybody have any moral (?) objections
> against the idea that value_initialized<T> might hold a
> non-value-initialized object?
>
> Personally I think it would be useful to allow the wrapped object to be
> direct-initialized. But I do think there's a small risk that the new
> explicit constructor might cause ambiguities in legacy user code.
> Therefor I suggested adding an extra "tag" parameter to the new
> constructor, of a new type, boost::direct_initialized_t:
>
> struct direct_initialized_t { };
> value_initialized(T const&, direct_initialized_t)
>
> Does anyone else also think that's a good idea? Or does anyone prefer
> the explicit value_initialized(T const&) constructor originally proposed
> by Edward?
>
> See also the thread starting at:
> "Re: [boost] Transfer of Maintenance Rights (utility/value_init)"
> http://lists.boost.org/Archives/boost/2010/03/164125.php
>
> Kind regards,
>
> Niels

Is defining a new template class (e.g., value_or_direct_initialized<T>,
or whatever) out of the question? Just a suggestion, and not confident
it's a good one...

- Jeff


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