Bug 16117 – std.experimental.allocator does not work with non default constructible types

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-06-03T12:21:52Z
Last change time
2020-03-21T03:56:34Z
Assigned to
No Owner
Creator
Maik Klein

Comments

Comment #0 by maikklein — 2016-06-03T12:21:52Z
See https://forum.dlang.org/post/[email protected] for more information Test case: import std.experimental.allocator; struct Foo{ @disable this(); } auto foos = theAllocator.makeArray!Foo(100); Error messsage: ../../.dub/packages/experimental_allocator-2.70.0-b1/src/std/experimental/allocator/package.d(576,34): Error: variable std.experimental.allocator.uninitializedFillDefault!(Foo).uninitializedFillDefault.t default construction is disabled for type immutable(Foo) ../../.dub/packages/experimental_allocator-2.70.0-b1/src/std/experimental/allocator/package.d(612,36): Error: template instance std.experimental.allocator.uninitializedFillDefault!(Foo) error instantiating source/breeze/util/algebraic.d(91,43): instantiated from here: makeArray!(Foo, IAllocator)
Comment #1 by public — 2016-06-03T13:02:04Z
I am insisting that there is no bug and the error message is legit. This code doesn't compile either: ``` struct Foo{ @disable this(); } Foo[10] foo; // Error: variable test.foo default construction is disabled for type Foo[10] ```
Comment #2 by andrei — 2016-06-03T13:29:43Z
Good point. Should work if the constructor is passed some argument: import std.experimental.allocator; struct Foo{ @disable this(); this(int) {} } auto foos = theAllocator.makeArray!Foo(100, 42);