Allocate an Array!T on the heap?

Tobias Pankrath tobias at pankrath.net
Fri Jun 22 05:06:27 PDT 2012


On Friday, 22 June 2012 at 10:19:13 UTC, Timon Gehr wrote:
> On 06/22/2012 08:45 AM, Tobias Pankrath wrote:
>> import std.container;
>>
>> struct A {};
>>
>> void main()
>> {
>> Array!(A)* arr = new Array!(A);
>> }
>>
>> yields
>>
>>
>> bug.d(7): Error: template std.container.Array!(A).Array.__ctor 
>> does not
>> match any function template declaration
>> /usr/include/d/std/container.d(1625): Error: template
>> std.container.Array!(A).Array.__ctor(U) if
>> (isImplicitlyConvertible!(U,T)) cannot deduce template 
>> function from
>> argument types !()()
>>
>
> This seems to work:
>
> import std.container;
>
> struct A {};
>
> void main() {
>     auto arr = new Array!A(A.init);
> }

Thanks.



More information about the Digitalmars-d-learn mailing list