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
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
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;
> >
> >
st
> > {
> >
> > return this;
> >
> > }
> >
> > int[] _val;
> >
> > }
> >
> > void main()
> > {
> > }
> >
> >
> > I get the error message
> >
> > d.d(5): E
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
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
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