Baffled by compilation error for formattedRead

Justin Whear via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu May 7 16:23:08 PDT 2015


On Thu, 07 May 2015 23:10:26 +0000, PhilipDaniels wrote:

> Why do the first two fail to compile but the last one does?! I cannot
> see any difference between the 's2' case and the second case, it is a
> completely mechanical source code transformation I have made.

formattedRead takes its input by ref and consumes it.  Your first two 
attempts are both passing the result of functions (dropExactly and 
opSlice) which are temporary rvalues and can thus not be passed by 
reference.  Here's more reading on the subject of rvalues: http://
ddili.org/ders/d.en/lvalue_rvalue.html


More information about the Digitalmars-d-learn mailing list