Init const fixed-sixed array in ctor
Jonathan M Davis
jmdavisProg at gmx.com
Fri Jun 17 19:07:25 PDT 2011
On 2011-06-17 18:18, bearophile wrote:
> Jonathan M Davis:
>
> Sure, it's a special case where setting that one element sets
>
> > the whole array, but making that work would be special casing for such an
> > array and complicate the compiler for little benefit.
>
> Don't worry, I have defined the array of length one just because I like to
> minimize my examples :-)
>
> > Now, if
> > array = [c];
> > doesn't work, _then_ we have a problem.
>
> This doesn't compile, nor several variants of it:
>
>
> struct Foo {
> const char[1] array;
> this(char c) {
> array = [c];
> }
> }
> void main() {}
Then that's a problem, since that makes initializing the array dynamically
impossible. Definitely worthy of a bug report.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list