Re: RefRange behavior

2018-03-14 Thread Alex via Digitalmars-d-learn
On Wednesday, 14 March 2018 at 10:22:45 UTC, Alex wrote: Is there a simple workaround, maybe? ok, the workaround would be to enumerate the member and to use the former notation.

RefRange behavior

2018-03-14 Thread Alex via Digitalmars-d-learn
Hi all, given this: ´´´ import std.range; size_t[] arr; struct S { RefRange!(size_t[]) member; } void fun(ref size_t numByRef){} void main() { arr.length = 42; S s; s.member = refRange(); static assert(__traits(compiles, fun(s.member[0

Re: refRange with non copyable struct

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 19:39:25 Stanislav Blinov via Digitalmars-d-learn wrote: > On Monday, 17 April 2017 at 19:00:44 UTC, Jonathan M Davis wrote: > > Because otherwise, it's not acting like a reference to the > > original range, which is the whole point of RefRange. The >

Re: refRange with non copyable struct

2017-04-17 Thread Stanislav Blinov via Digitalmars-d-learn
On Monday, 17 April 2017 at 19:00:44 UTC, Jonathan M Davis wrote: Because otherwise, it's not acting like a reference to the original range, which is the whole point of RefRange. The correct solution would probably be to @disable opAssign in the case where the original range can't

Re: refRange with non copyable struct

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
t; copyable. It might be reasonable for RefRange to be enhanced so > > that it doesn't compile in opAssign if the range isn't > > copyable, but I'd have to study RefRange in depth to know what > > the exact consequences of that would be, since it's been quite > > a

Re: refRange with non copyable struct

2017-04-17 Thread Jerry via Digitalmars-d-learn
On Monday, 17 April 2017 at 18:07:36 UTC, Jonathan M Davis wrote: In this particular case, it looks like the main problem is RefRange's opAssign. For it to work, the type needs to be copyable. It might be reasonable for RefRange to be enhanced so that it doesn't compile in opAssign

Re: refRange with non copyable struct

2017-04-17 Thread Jerry via Digitalmars-d-learn
On Monday, 17 April 2017 at 18:07:36 UTC, Jonathan M Davis wrote: Non-copyable types tend to wreak havoc with things - Jonathan M Davis Basicly what I use this for is to combine RAII with ranges. Which I find quite useful when doing DB queries and the data is lazily fetched since this allows

Re: refRange with non copyable struct

2017-04-17 Thread Jonathan M Davis via Digitalmars-d-learn
On Monday, April 17, 2017 17:23:32 Jerry via Digitalmars-d-learn wrote: > Hello guys, so I wanted to have a noncopyable range on the stack. > So my thoughts was to make it non copyable and use refRange > whenever I want to use it with map and others. > > But I got a compiler warnin

refRange with non copyable struct

2017-04-17 Thread Jerry via Digitalmars-d-learn
Hello guys, so I wanted to have a noncopyable range on the stack. So my thoughts was to make it non copyable and use refRange whenever I want to use it with map and others. But I got a compiler warning when doing so like this: import std.range; void main() { NonCopyable v

RefRange

2012-08-26 Thread David
It's a RefRange, but not completly ... Can somebody explain me that behaviour? http://dpaste.dzfl.pl/643de2a3

Re: RefRange

2012-08-26 Thread Ali Çehreli
On 08/26/2012 08:41 AM, David wrote: It's a RefRange, but not completly ... Can somebody explain me that behaviour? http://dpaste.dzfl.pl/643de2a3 According to its documentation, RefRange works differently whether the original range is a ForwardRange or not: http://dlang.org/phobos

Re: RefRange

2012-08-26 Thread Jonathan M Davis
On Sunday, August 26, 2012 17:41:45 David wrote: It's a RefRange, but not completly ... Can somebody explain me that behaviour? http://dpaste.dzfl.pl/643de2a3 refRange simply returns the original range if it's an input range rather than a forward range, since normally, when you have an input

Re: RefRange

2012-08-26 Thread Jonathan M Davis
On Sunday, August 26, 2012 10:17:13 Jonathan M Davis wrote: On Sunday, August 26, 2012 17:41:45 David wrote: It's a RefRange, but not completly ... Can somebody explain me that behaviour? http://dpaste.dzfl.pl/643de2a3 refRange simply returns the original range if it's an input range

Re: RefRange

2012-08-26 Thread David
Am 26.08.2012 20:07, schrieb Jonathan M Davis: On Sunday, August 26, 2012 10:17:13 Jonathan M Davis wrote: On Sunday, August 26, 2012 17:41:45 David wrote: It's a RefRange, but not completly ... Can somebody explain me that behaviour? http://dpaste.dzfl.pl/643de2a3 refRange simply returns

Re: RefRange

2012-08-26 Thread David
Am 26.08.2012 18:06, schrieb Ali Çehreli: On 08/26/2012 08:41 AM, David wrote: It's a RefRange, but not completly ... Can somebody explain me that behaviour? http://dpaste.dzfl.pl/643de2a3 According to its documentation, RefRange works differently whether the original range is a ForwardRange

Re: RefRange

2012-08-26 Thread Ali Çehreli
On 08/26/2012 02:21 PM, David wrote: I tried to implement a .save method, which uhm, just didn't work together with RefRange (isForwardRange!T succeeded, but isForwardRange!(RefRange!T) failed). What version of dmd? What is the code? When I add the following lines to the beginning of main

Re: RefRange

2012-08-26 Thread David
Am 26.08.2012 23:33, schrieb Ali Çehreli: On 08/26/2012 02:21 PM, David wrote: I tried to implement a .save method, which uhm, just didn't work together with RefRange (isForwardRange!T succeeded, but isForwardRange!(RefRange!T) failed). What version of dmd? What is the code? When I add