On Sat, 18 Sep 2010 17:20:31 -0400, Jonathan M Davis <jmdavisp...@gmx.com> 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 to make a deep copy (that's what it does if it doesn't have an array in it anyway). I suppose whether it really needs to be const or not depends on what you're trying to do with it. I'm definitely trying to create a range here, and if save() is supposed to make a copy of the range, whether that needs to be a shallow copy or a deep copy depends on what the std.algorithm stuff does with it. When I think copy, I usually think deep copy, but that's not necessarily the case. I will have to enquire as to the intent of save(). For value types, shallow copy and deep copy are the same, so it's not an issue. But for class ranges or struct ranges with references, it does become an issue.

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.

-Steve

Reply via email to