lookup fields struct
evilrat
evilrat666 at gmail.com
Sun May 26 07:59:58 PDT 2013
On Sunday, 26 May 2013 at 14:19:13 UTC, mimi wrote:
> Hi!
>
> I am want to get list of fields types and offsets in struct by
> the template.
>
> I.e., lookup through this struct:
>
> struct S {
>
> int a;
> string b;
> someptr* c;
>
> };
>
> template Lookup!( S )(); returns something as:
>
> field #0, int, offset 0
> field #1, string, offset 8,
> field #2, someptr, offset 16
>
> How I can do this?
std.traits and built-in traits should do what u asking.
http://dlang.org/phobos/std_traits.html
http://dlang.org/traits.html
More information about the Digitalmars-d-learn
mailing list