[question] Access from UDA constructor to parent symbol
Ali Çehreli via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Dec 26 18:05:27 PST 2016
On 12/26/2016 02:04 PM, crimaniak wrote:
> So my main question: how it is possible to do such thing?
Just to make sure we're on the same page: :)
* There is 'interface' in addition to 'class'
* If all you want is to check, then you can write template constraints
by following the example of std.range.isInputRange.
With that aside, what you need is generally achieved by a mixin:
@implements!I1
struct S1
{
// ...
}
template ValidateInterfaces() {
// Go through all members of the module here
// Identify the ones having the 'implements' UDA
// The useful tools here are
// __traits(getAttributes)
// __traits(allMembers)
// __traits(getMember)
}
mixin ValidateInterfaces;
Ali
More information about the Digitalmars-d-learn
mailing list