Transforming a range back to the original type?

Jacob Carlborg doob at me.com
Fri May 4 12:24:05 PDT 2012


On 2012-05-04 19:15, Jonathan M Davis wrote:
> On Friday, May 04, 2012 13:46:33 Jacob Carlborg wrote:
>> I give up. Apparently you don't think it's useful.
>
> If you can come up with an example/reason why it would actually be useful,
> then great. But I don't see why it would ever matter what the original
> container type really was.
>
> You need the original range type in cases like std.container's remove
> function, but then the range must _be_ the original range type from that exact
> container in order to work, and there's no way that you could turn a wrapped
> range into the proper range for that, since you'd have to create a new
> container, and then the resultant range would be for the wrong container. And
> that's the only situation that I can think of where it really matters what the
> original container type was. If you want to construct a new container out of a
> range, then great, but since it's a new container, I don't see how it matters
> what the original container was unless you intend to assign the result to the
> new container or somesuch, in which case, you would already have access to the
> type, because you'd have a variable to assign to.
>
> - Jonathan M Davis

I have no problem if there's a new collection. I'm saying of the same 
_type_, not the same _collection_. As I've said in other posts in this 
thread, I mostly just want to assign the result of a range operation 
back to the original variable. Preferably I would like to not have to 
call any extra functions or constructors but that's not how ranges work.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list