Why does this not compile?
Diego
diego at example.com
Tue Mar 6 10:16:59 UTC 2018
On Tuesday, 6 March 2018 at 10:03:54 UTC, Shachar Shemesh wrote:
> void main() {
> struct S {
> uint value;
>
> ~this() {
> }
> }
>
> const S a = S(12);
> S b = a;
> }
>
You cannot assign a const element (`a`) to a non-const element
(`b`) in `S b = a` expression. To make de assignment, you have to
cast a to a non-constant expression:
S b = cast(S)a;
Or make `b` as const:
const S b = a;
Or, better, use auto keyword:
auto b = a;
More information about the Digitalmars-d
mailing list