add uda (e.g. @csvIgnore) support in std.csv?

mw mingwu at gmail.com
Sat Oct 10 04:31:20 UTC 2020


On Tuesday, 8 September 2020 at 04:53:26 UTC, mw wrote:
> Hi,
>
> I'm trying this example:
>
> https://dlang.org/phobos/std_csv.html
>
> ```
> struct Layout
> {
>     string name;
>     int value;
>     double other;
>
>     @csvIgnore
>     Layout* parent;  // add extra pointer
> }
>
> auto records = text.csvReader!Layout(';');
> ```
>
> Right now, if we add this extra pointer, the compiler will 
> error out:
>
> https://run.dlang.io/is/EvU6Ee
>
> /dlang/dmd/linux/bin64/../../src/phobos/std/conv.d(223): Error: 
> template std.conv.toImpl cannot deduce function from argument 
> types !(Layout*)(string), candidates are:
> ...
>
> I think if we can add add uda (e.g. @csvIgnore) support in 
> std.csv, it will make the library more flexible to use.
>
> Thoughts?

I do run into this problem today, i.e. my struct need some extra 
non-simple-scalar fields (e.g. SysTime) other than those defined 
in the csv file, I'm wondering what kind of work-around people 
use in such situation?

Thanks.



More information about the Digitalmars-d mailing list