Mercurial > projects > qtd
comparison d2/qtd/Array.d @ 350:31520b2c0b3c
Removed dependency on parent trait and stringof
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Thu, 20 May 2010 15:49:08 +0300 |
parents | 96a75b1e5b26 |
children | 9784459f0750 |
comparison
equal
deleted
inserted
replaced
349:925386e0e780 | 350:31520b2c0b3c |
---|---|
33 | 33 |
34 break; | 34 break; |
35 } | 35 } |
36 } | 36 } |
37 } | 37 } |
38 | |
39 /** | |
40 Allocates a dynamic array at compile time. | |
41 */ | |
42 T[] newArray(T)(size_t len, T[] from = []) | |
43 { | |
44 if (len == from.length) | |
45 return from; | |
46 | |
47 if (!from.length) | |
48 from = [T.init]; | |
49 | |
50 if (from.length < len) | |
51 return newArray!T(len, from ~ from); | |
52 | |
53 return from[0..len]; | |
54 } |