Duplicate class/interface/struct completely

Michelle Long HappyDance321 at gmail.com
Tue Mar 26 05:29:08 UTC 2019


Given a class/interface/struct, I'd like to duplicate it's design 
exactly, as if I copied and pasted directly from the source and 
just changed the name. I need to inspect the contents too. Is 
this possible with D?

Main things I'm thinking will fail are (multiple) alias this 
unless there is a way to get which variables are aliased to this.

The idea is to be able to make sure one can modify a class and 
drop it in for the original and it work in all cases. With alias 
this, it can fail unless we can alias it too.

struct X { int y; alias this y; }

struct XX { mixin DupStruct!X; }

If DupStruct cannot handle the alias this then XX can fail to 
mimic X completely.




More information about the Digitalmars-d-learn mailing list