https://d.puremagic.com/issues/show_bug.cgi?id=9506



--- Comment #11 from Peter Alexander <[email protected]> 2014-02-08 
00:28:05 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > (In reply to comment #8)
> > > Eh, shouldn't it just call t.toString() without even needing to look at 
> > > alias
> > > this? I'm leaning toward either phobos bug or template
> > > specialization/constraint change.
> > 
> > Due to the alias this, the class is a range, so it calls the range version 
> > of
> > writeln.
> 
> Since a recent compiler enhancement it is easy to extract 'alias this'
> information from an aggregate. writeln() should do the sane thing and check
> this before attempting to consume the range. This might be special behavior,
> but writeln() should IMHO not have side-effects.

writeln *must* have side-effects to work with input ranges. How do you consume
a one-pass input without modifying it?

Alias this isn't the problem. Any reference type range will be consumed.

auto a = inputRangeObject([1, 2, 3]);
writeln(a); // [1, 2, 3]
writeln(a); // []

If you don't want it to be consumed, you need to call .save

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

Reply via email to