Referencer

Jonathan M Davis via Digitalmars-d digitalmars-d at puremagic.com
Fri Nov 20 12:35:34 PST 2015


On Friday, 20 November 2015 at 18:23:57 UTC, HaraldZealot wrote:
> All ranges in Phobos pass by value, but if I have output range 
> with state like cumulative statistics this is useless.

Realistically, output ranges really should be passed by ref, but 
I'm not sure whether that's really being done in Phobos at this 
point - though output ranges aren't used all that much in Phobos 
anyway. It's mostly input ranges, which are a very different 
beast.

But if you just make it so that your output range is a reference 
type (e.g a class or a struct with a single pointer to its 
state), then you get around any issues caused by a function not 
accepting its output range by ref.

- Jonathan M Davis


More information about the Digitalmars-d mailing list