Pointer to variables in D

Timon Gehr timon.gehr at gmx.ch
Thu Apr 26 00:54:36 PDT 2012


On 04/26/2012 04:43 AM, Victor Vicente de Carvalho wrote:
> Hi there,
>
> In c++ one can access a pointer to a class/struct variable using this
> semantic:
>
> struct C {
> int x;
> };
>
> int C::* ptr = &C::x;
>
> C foo;
>
> foo.*ptr = 10;
> assert(foo.x == 10);
>
> It is possible to do something like that on D? I've searched through the
> forum & documentation but didn't found anything.
>
> Also, the reason of this is that I'm studying a way to map a POD
> structure based from a dynamic, data-driven structure. Something like
> "get a JSON and map it to a structure automagically". There is a nicer
> way to do that in D?
>
>
>

http://www.drdobbs.com/blogs/cpp/231600610


More information about the Digitalmars-d-learn mailing list