On Tuesday, 29 September 2015 at 07:09:35 UTC, Jacob Carlborg
wrote:
This looks pretty cool. Unfortunately the original code needs
to be contained inside a template :( .
Yeah. You could put it in a module too (my original plan was to
write about "module mything_impl; code here" and "module mything;
mixin magic_from_mything_impl;" but there's a bit more difficulty
with that and forwarding all members you don't want to transform.
Though, I just had an idea on how that might be simplified....
don't recreate them, just alias them!
So, conceptually, you'd do something like:
template transformer(alias member) {
static if(hasUDA!(member, thing))
mixin(transformed_version_of_member());
else
alias member = member;
}
mixin staticMap!(AllMembers!impl_module, transformer);
So you bring in the original thing via alias in much the same way
I brought it in via template mixin, then do the rest basically
the same.
That *should* work and not even be all that much more code. Then
you don't need to wrap anymore. Though it does still need to be
in a separate something, whether input module or struct, from the
output.