Re: Getting a range over a const Container

2012-07-20 Thread Jonathan M Davis
On Friday, July 20, 2012 17:15:53 Ellery Newcomer wrote: > On 07/19/2012 06:09 PM, Ellery Newcomer wrote: > > On 07/19/2012 02:51 AM, Artur Skawina wrote: > >> Range!Node opSlice() { return Range!Node(first); } > >> Range!(const Node) opSlice() const { return Range!(const > >> > >> Node)(first); }

Re: Getting a range over a const Container

2012-07-20 Thread Ellery Newcomer
On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } it looks like you could almost merge these two into one using

Re: Getting a range over a const Container

2012-07-19 Thread Ellery Newcomer
On 07/19/2012 06:18 PM, Ali Çehreli wrote: Now the output is different: non-const foo called on a const foo called on b Ali cool beans, thanks.

Re: Getting a range over a const Container

2012-07-19 Thread Ali Çehreli
On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why this is possible? It is the same as in C++.

Re: Getting a range over a const Container

2012-07-19 Thread Ali Çehreli
On 07/19/2012 06:16 PM, Ali Çehreli wrote: On 07/19/2012 06:09 PM, Ellery Newcomer wrote: On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why t

Re: Getting a range over a const Container

2012-07-19 Thread Ellery Newcomer
On 07/19/2012 02:51 AM, Artur Skawina wrote: Range!Node opSlice() { return Range!Node(first); } Range!(const Node) opSlice() const { return Range!(const Node)(first); } anyone mind cluing me in on why this is possible?

Re: Getting a range over a const Container

2012-07-19 Thread Matthias Walter
On 07/19/2012 06:44 AM, Jonathan M Davis wrote: > On Thursday, July 19, 2012 04:39:26 Francisco Soulignac wrote: >> So, my question is how can I (correctly) traverse a const SList, >> const DList, etc? > > Right now? I'm pretty sure that that's impossible. Hopefully that will > change, > but get

Re: Getting a range over a const Container

2012-07-19 Thread Artur Skawina
On 07/19/12 06:39, Francisco Soulignac wrote: > it's been a while since this question, and I don't know how to solve > it either. The following code passes all the test using the last > version of dmd (2.059). > > import std.container, std.algorithm; > > //non const case > void assertequal(T)(SL

Re: Getting a range over a const Container

2012-07-18 Thread Jonathan M Davis
On Thursday, July 19, 2012 04:39:26 Francisco Soulignac wrote: > So, my question is how can I (correctly) traverse a const SList, > const DList, etc? Right now? I'm pretty sure that that's impossible. Hopefully that will change, but getting const and ranges to work together can be rather difficul

Re: Getting a range over a const Container

2012-07-18 Thread Francisco Soulignac
Hi all, it's been a while since this question, and I don't know how to solve it either. The following code passes all the test using the last version of dmd (2.059). import std.container, std.algorithm; //non const case void assertequal(T)(SList!(T) l, int[] r) { assert(equal(l[], r)); } /

Re: Getting a range over a const Container

2012-06-15 Thread Jonathan M Davis
On Friday, June 15, 2012 09:14:45 Matthias Walter wrote: > Hi, > > I have a const std.container object (e.g., a const(Array!int)) of which > I'd like to have a range which can traverse that container having > read-only access. This does not seem to be possible with opSlice(). Is > there an alterna

Getting a range over a const Container

2012-06-15 Thread Matthias Walter
Hi, I have a const std.container object (e.g., a const(Array!int)) of which I'd like to have a range which can traverse that container having read-only access. This does not seem to be possible with opSlice(). Is there an alternative? Best regards, Matthias