| |
 | Posted by Jesse Phillips | Permalink Reply |
|
Jesse Phillips 
| https://issues.dlang.org/show_bug.cgi?id=23383
Jesse Phillips <Jesse.K.Phillips+D@gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |Jesse.K.Phillips+D@gmail.co
| |m
--- Comment #1 from Jesse Phillips <Jesse.K.Phillips+D@gmail.com> ---
I think you're probably right, but what about
class Layout
{
int value;
double other;
string name;
}
struct Cache {
Layout data;
alias data this;
int extra_field; // un-comment to see the error
static Cache opCall(Layout d) {
Cache c;
c.data = d;
return c;
}
}
void main()
{
import std.csv;
import std.stdio: write, writeln, writef, writefln;
import std.algorithm.comparison : equal;
import std.algorithm : map;
string text = "a,b,c\nHello,65,2.5\nWorld,123,7.5";
auto records =
text.csvReader!Layout(["b","c","a"])
.map!(x => Cache(x)) ; // Read only these column
foreach (r; records) writeln(r.name);
}
--
|