On Saturday 18 September 2010 06:45:51 Ivo Kasiuk wrote: > 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:
No. The whole point here is to have a save() method. It's for a range, and forward ranges have the save() method because a range doesn't necessarily have to be a struct and just doing a straight up copy with a class doesn't work. > > 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); > } For some reason, I haven't gotten postblit to work. Outright creating a new one that's the same rather than trying to use the automatic copy mechanisms does seem like a good idea though. Thanks. - Jonathan M Davis