On Wednesday, 29 July 2015 at 20:26:53 UTC, Tofu Ninja wrote:
If you write:

@satisfies!(isInputRange, MyRange) struct MyRange { ... }

the UDA can check it self, it really works as expected. Which is why I suggested a way to get whatever the UDA is attached to automatically in my other post.

A UDA can reference the thing it's being attached to with no problems.
For example, this works 100% as expected right now...

@UDA!testS struct testS // UDA fails to instantiate because testS is not an inputRange!
{
        
}

template UDA(alias a)
{
        import std.range;
        static assert(isInputRange!a);
}

The only thing that would be needed to make this a nice solution is some syntax sugar to automatically get whatever the UDA is attached to, which is why I suggested this:

template UDA(alias a = __UDA_ATTACHMENT__) { ... }

Reply via email to