Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 19:03:12 UTC, Ali Çehreli wrote: I am making the following comment to have others confirm, as well as remind others about a potential problem. On 06/13/2014 11:14 AM, Andre wrote: > unittest > { > auto intList = new List!int(1,2,3); [...] > class List(T) > { >

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread Ali Çehreli via Digitalmars-d-learn
I am making the following comment to have others confirm, as well as remind others about a potential problem. On 06/13/2014 11:14 AM, Andre wrote: > unittest > { > auto intList = new List!int(1,2,3); [...] > class List(T) > { > private T[] items; > > this(T[] items...) > {

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread monarch_dodra via Digitalmars-d-learn
On Friday, 13 June 2014 at 18:14:10 UTC, Andre wrote: Hi, I have a template class "List" which should provide generic list functionality. In my use case, using a class instead a struct is more comfortable. Following unittest fails, although the forward range implements the save method. unit

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread Andre via Digitalmars-d-learn
Am 13.06.2014 20:22, schrieb H. S. Teoh via Digitalmars-d-learn: [...] Generally, it's a bad idea to conflate a container with a range over its contents. In this sense, built-in arrays are a very bad example, because they show precisely this sort of conflation. But they get away with it because

Re: User defined forward range - foreach initializes f.r.

2014-06-13 Thread H. S. Teoh via Digitalmars-d-learn
On Fri, Jun 13, 2014 at 08:14:11PM +0200, Andre via Digitalmars-d-learn wrote: > Hi, > > I have a template class "List" which should provide generic list > functionality. In my use case, using a class instead a struct > is more comfortable. > > Following unittest fails, although the forward range

User defined forward range - foreach initializes f.r.

2014-06-13 Thread Andre via Digitalmars-d-learn
Hi, I have a template class "List" which should provide generic list functionality. In my use case, using a class instead a struct is more comfortable. Following unittest fails, although the forward range implements the save method. unittest { auto intList = new List!int(1,2,3);