bearophile <[email protected]> wrote:
> Don:
> 
>> As I said in my other post, we could deal with this using a CTFE library 
>> solution.
> 
> Currently this works:
> 
> ubyte[10] a = [1, 2];
> void main() {}
> 
> But if you write this, I think padArrayLiteral returns an int[], so D
> refuses the implicit cast:
> 
> ubyte[10] a = padArrayLiteral(256, [1, 2]);
> void main() {}
>

Why you're padding to 256 entries when a ubyte[10] is needed? ;)
 
> So I think you have to write something like:
> 
> ubyte[10] a = padArrayLiteral!ubyte(256, [1, 2]);
> void main() {}
> 
> Bye,
> bearophile

Or:

auto a = staticArray!(ubyte[10])([1, 2]);

(staticArray() is like array() which can take arbitrary ranges, but it
returns a static array formed by take-ing the range and padding with
ElementType.init.)

Reply via email to