www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Allocate an Array!T on the heap?

reply "Tobias Pankrath" <tobias pankrath.net> writes:
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 !()()
Jun 21 2012
next sibling parent Timon Gehr <timon.gehr gmx.ch> writes:
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); }
Jun 22 2012
prev sibling parent "Tobias Pankrath" <tobias pankrath.net> writes:
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.
Jun 22 2012