Boost logo

Boost :

Subject: [boost] [utility/value_init] boost::value_initialized<T> direct-initialized?
From: Niels Dekker - address until 2010-10-10 (niels_address_until_2010-10-10_at_[hidden])
Date: 2010-03-30 16:25:52

Can anybody please have a look at the following feature request by
Edward Diener? 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)"

Kind regards,


Niels Dekker
Scientific programmer at LKEB, Leiden University Medical Center

Boost list run by bdawes at, gregod at, cpdaniel at, john at