Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-20 Thread Jonathan M Davis
On Monday, September 20, 2010 04:11:05 Steven Schveighoffer wrote: > You don't want a deep copy of a range. All you want to copy is the > iteration state, not the data. > > save is definitely supposed to be shallow. I.e. you should copy the range > itself, not what the range points to. That mak

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-20 Thread Steven Schveighoffer
On Sat, 18 Sep 2010 17:20:31 -0400, Jonathan M Davis wrote: On Saturday 18 September 2010 09:58:15 Steven Schveighoffer wrote: In reality, you cannot make save const, unless you want to do a deep copy (but I recommend against that, save should be a quick operation). Well, I was trying

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Jonathan M Davis
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; > > > >

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Jonathan M Davis
st > > { > > > > return this; > > > > } > > > > int[] _val; > > > > } > > > > void main() > > { > > } > > > > > > I get the error message > > > > d.d(5): E

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Steven Schveighoffer
expression (this) of type const(S) to S Yes, because you are converting "this" from a const(S) to an S to return it. Try: @property const(S) save() const { return this; } If I remove const from save(), then it works, but with const there, it doesn't. If I change _val to

Re: Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Ivo Kasiuk
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 simp

Error: cannot implicitly convert expression (this) of type const(S) to S

2010-09-18 Thread Jonathan M Davis
Okay, if I try and compile the following program. struct S { @property S save() const { return this; } int[] _val; } void main() { } I get the error message d.d(5): Error: cannot implicitly convert expression (this) of type const(S) to S If I remove const from save