On Thursday, 5 June 2014 at 13:51:35 UTC, Rene Zwanenburg wrote:
I depend heavily on RAII in a project I'm working on. Since structs in dynamic arrays never have their destructors called I'm using Array!T instead. A pattern that comes up often is that I have some input range of T's which need to be stored in a member Array!T. However Array is not an output range so I can't use

inputRange.copy(someArray);

I understand the difference between a container and a range iterating over that container. However I do think a container is an output range.

Should I file an enhancement request or is there something fundamentally wrong with this idea? For Array it should be as simple as adding

alias doPut = insertBack;

Well, one issue is that for a "Range", "put" really just means overwrite the front element, and pop it. So...

Array!int myArray = ...:
copy([1, 2, 3], myArray);   //(1)
copy([1, 2, 3], myArray[]); //(2)

In this situation, (1) and (2) would have different meaning.

This whole mess comes from "Writeable InputRange" being considered an OutputRange... Arguably, an OutputRange should be nothing more than a "sink", which an InputRange is not.

Reply via email to