On Sunday, 17 March 2013 at 04:54:58 UTC, Ali Çehreli wrote:
On 03/15/2013 02:57 AM, Andrea Fontana wrote:
> On Friday, 15 March 2013 at 03:44:51 UTC, Ali Çehreli wrote:
> - I've added a method (it's an "hack" to make it works):
> this(this)
> {
> auto dummy = lazyCache.newView(lazyCache.cache.ptr);
> myId = dummy.myId;
> }

I am not sure why that was necessary. Additionally, some of the member functions like empty() can be made const.

If not something like:

foreach(e; yourrange)  // <-- here this(this) is called
{
   writeln(e);
}

foreach(e; yourrange) // <-- here this(this) is called
{
   writeln(e);
}

Print:
1 2 3 4 5 6

instead of:
1 2 3 1 2 3  as "expected"

But it's an hack, you should know a better way to do it :)
When a struct is copied like in example above, every copy should retain its own pointer to data (restarted from begin).

Reply via email to