<div dir="ltr">If you just want to not repeat fields and methods you can use alias this or mixins:<div><a href="https://run.dlang.io/is/0UkjTe">https://run.dlang.io/is/0UkjTe</a><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Oct 11, 2017 at 2:07 PM, drug via Digitalmars-d-learn <span dir="ltr"><<a href="mailto:digitalmars-d-learn@puremagic.com" target="_blank">digitalmars-d-learn@puremagic.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">11.10.2017 14:37, ANtlord пишет:<div><div class="h5"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Hello dear community!<br>
<br>
I've met a little issue. How can I generate struct or class copying some fields and methods from another struct or class? I've found methods to get fields. They are std.traits.FieldNameTuple and std.traits.FieldTypeTuple but I can't find a method allows getting methods from struct or class.<br>
<br>
Other words I want to get fields and methods by string values and copy them to my struct. Is it possible? Or do I want something strange?<br>
<br>
Thanks in advance. Sorry if my English is not clear.<br>
</blockquote></div></div>
You need a wrapper, but it would include all fields and methods from base struct/class and you just expose only that you need. So it's quite possible except I don't known how you can exclude needless fields.<br>
But FieldNameTuple etc are not enough, your best friend is __traits(allMember, ...), iterating over its output and making decision what current symbol is and processing it according to its features. It's not trivial but not very complex.<br>
</blockquote></div><br></div>