Formatted read consumes input

Jonathan M Davis jmdavisProg at gmx.com
Fri Sep 7 08:04:36 PDT 2012


On Friday, September 07, 2012 10:52:07 Steven Schveighoffer wrote:
> We have three situations:
> 
> 1. input range is a ref type already (i.e. a class or a pImpl struct), no
> need to pass this by ref, just wastes cycles doing double dereference.
> 2. input range is a value type, and you want to preserve the original.
> 3. input range is a value type, and you want to update the original.
> 
> I'd like to see the library automatically make the right decision for 1,
> and give you some mechanism to choose between 2 and 3.  To preserve
> existing code, 3 should be the default.

Does it _ever_ make sense for a range to be an input range and not a forward 
range and _not_ have it be a reference type? Since it would be implicitly 
saving it if it were a value type, it would then make sense that it should 
have save on it. So, I don't think that input ranges which aren't forward 
ranges make any sense unless they're reference types, in which case, there's 
no point in taking them by ref, and you _can't_ preserve the original.

- Jonathan M Davis


More information about the Digitalmars-d mailing list