Boost logo

Boost :

Subject: Re: [boost] [utility/value_init] boost::value_initialized<T> direct-initialized?
From: Jeffrey Hellrung (jhellrung_at_[hidden])
Date: 2010-03-31 04:42:06


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?
>
> Jeffrey Hellrung wrote:
>> 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...
>
> Thanks for the suggestion, Jeffrey! I like it, actually. :-) Maybe we
> could simply call the new template class boost::initialized<T>.

initialized<T> was actually my initial thought; I chose a crappy name on
purpose ;)

> I can think of two ways to implement boost::initialized<T> (and adapt
> value_initialized<T> accordingly):
[...]

I'm partial to value_initialized being implemented in terms of
initialized, but it is strictly an implementation detail, right?

Also, your initialized<T> does not have a default constructor. This
makes sense, but I'm just double-checking that this is a conscious
decision and not an oversight.

- Jeff


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