On 8/8/17 3:43 PM, Anonymouse wrote:
On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven Schveighoffer wrote:
I wouldn't use formattedRead, as I think this is going to allocate
temporaries for a and b.
What would you suggest to use in its stead? My use-case is similar to
the OP's in that I have a string of tokens that I want split into
variables.
using splitter(","), and then parsing each field using appropriate
function (e.g. to!)
For example, the OP's code, I would do:
auto r = line.splitter(",");
a = r.front;
r.popFront;
b = r.front;
r.popFront;
c = r.front.to!int;
It would be nice if formattedRead didn't use appender, and instead
sliced, but I'm not sure it can be fixed.
Note, one could make a template that does this automatically in one line.
-Steve