std.experimental.alloctor does not work with non default constructible types

maik klein via Digitalmars-d digitalmars-d at puremagic.com
Fri Jun 3 04:57:10 PDT 2016


On Friday, 3 June 2016 at 11:52:52 UTC, Andrei Alexandrescu wrote:
> On 6/3/16 7:47 AM, maik klein wrote:
>> I rely a lot on std.experimental.alloctor for my "game 
>> engine". I have
>> just finished creating my own version for "Algebraic" and I 
>> want to
>> disable to default construction as it would make no sense.
>>
>> I have also created my own containers, the problem is that I 
>> can not use
>> my version of "Algebraic" in any of my containers because all 
>> of them
>> are using std.experimental.alloctor.makeArray which can not be 
>> used with
>> non default constructible types.
>>
>> While I don't want to have any default constructed type of 
>> Algebraic, I
>> really don't care for uninitialized values that I will never 
>> use anyway.
>>
>> I am sure there is a workaround with unions but it would be 
>> nice if
>> makeArray/expandArray would just support non default 
>> constructible types.
>>
>> Thoughts?
>
> Looks like a bug. Do you have a short repro? -- Andrei

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)




More information about the Digitalmars-d mailing list