On Thursday, 25 February 2016 at 09:11:58 UTC, Atila Neves wrote:
On Thursday, 25 February 2016 at 01:57:37 UTC, Iakh wrote:
On Friday, 30 October 2015 at 14:39:47 UTC, Atila Neves wrote:
[...]

It could be better to extend UDA with checking and diagnostic functions

@IsInputRange
struct myRange {...

And some attrs not applicable for all things, extended UDA can handle it

Scanning for UDAs for a whole project isn't trivial and even worse optional.

Atila

I meant extend UDAs to match your proposal. But rules to build failFunc in both cases looks too sophisticated.
Simpler version could looks like this:

// Predicate:
enum bool checkConstraint(bool verbose) = /*Whatever you want*/

struct Struct{
mixin checkConstraint!(isOutputRange, int); // int represents tail template args
}

mixin checkConstrint!(...) adds this code:
static if(!isOutputRange!(Struct, int).checkConstraint!(No.verbose))
{
static assert(isOutputRange!(Struct, int).checkConstraint!(Yes.verbose));
}

Reply via email to