[Issue 9102] OutputRange should be ref parameter

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Feb 21 08:54:47 PST 2013


http://d.puremagic.com/issues/show_bug.cgi?id=9102



--- Comment #4 from Steven Schveighoffer <schveiguy at yahoo.com> 2013-02-21 08:54:46 PST ---
(In reply to comment #3)

> From these, I think that it is appropriate that a function to treat OutputRange
> with ref parameter.
> (std.range.put takes ref in the first argument as collateral evidence.)

If functions accepting output ranges only took ranges via ref, then you have to
make copies just to pass ranges to a function.

For example:

int[] array1 = [1,2,3,4];
int[] array2 = new int[](4);

// must make a copy of array2
auto array3 = array2;
copy(array1, array3);

Note also, the slice case:

int[] array4 = new int[](5);
copy(array1, array4[1..5]);

Such a call is not possible with ref qualifier.

With CRC32, it is not a valid output range, because put only affects
pass-by-value data.  I know the template to check for output range simply
checks if put can work with it, but I don't know if there is a valid way to
check for this in a template.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list