On Friday, 15 August 2014 at 16:51:20 UTC, Philippe Sigaud wrote:
On Friday, 15 August 2014 at 16:48:10 UTC, monarch_dodra wrote:
Make sure you don't use that if your type has elaborate
construction, or assumes a certain initial state (unless you
are actually emplacing your objects of course).
Hmm, what's elaborate construction? They are classes and have
constructors, of course. I assumed that this produced only
null's in the array.
Actually, my statement was inaccurate. More specifically, never
use anything that wasn't first properly initialized. Note that in
some cases, "operator=" is itself elaborate, meaning it will also
read data, so that's not a valid method of initialization.
uninitializedArray simply creates an array with unspecified data
in it.
You *could* just use "new" instead. It's not really any slower,
and has the advantage of being certifiably safe.