scoped classes

Stanislav Blinov via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 27 09:39:38 PDT 2017


On Thursday, 27 April 2017 at 15:47:38 UTC, Alex wrote:

> struct S
> {
> 	@disable this();
> 	@disable this(this);
> 	this(size_t dummy){}
> }
>
> Given a struct with an explicit constructor and a postblit. How 
> to make an array of it?

You mean with a disabled default ctor and postblit? You can't 
with built-in arrays. They expect that elements can be 
default-constructed and copied. Even std.container.Array in its 
current implementation won't help you there.
The only way to get around that is to devise your own array type 
that carefully deals with uninitialized storage and uses 
emplace/move/moveEmplace to store elements.



More information about the Digitalmars-d-learn mailing list