On Wednesday, 9 August 2017 at 13:36:46 UTC, Steven Schveighoffer
On 8/8/17 3:43 PM, Anonymouse wrote:
On Tuesday, 8 August 2017 at 16:00:17 UTC, Steven
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;
b = r.front;
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
The blog post Steve referred to has examples of this type
processing while iterating over lines in a file. A couple
different ways to access the elements are shown. AA access is