Error: cannot implicitly convert expression (this) of type const(S) to S
Ivo Kasiuk
i.kasiuk at gmx.de
Sat Sep 18 06:45:51 PDT 2010
Am Samstag, den 18.09.2010, 02:15 -0700 schrieb Jonathan M Davis:
> Okay, if I try and compile the following program.
>
> struct S
> {
> @property S save() const
> {
> return this;
> }
>
> int[] _val;
> }
>
> void main()
> {
> }
>
Actually, wouldn't it be much more simple to just copy the struct
instance directly, without a save() method:
S s1;
S s2 = s1;
And you could add a postblit to control the copy behavior concerning
_val.
Or if save() is supposed to behave different than normal copying maybe
something like this could be the solution:
S save() const {
return S(_val.dup);
}
More information about the Digitalmars-d-learn
mailing list