On 28-Sep-2015 23:25, Atila Neves wrote:
I've mentioned this many times before: template constraints are like unittest blocks with asserts in D: great that they're built-in easy to use. But when they fail, there's no help in figuring out why.
[snip]
I created an input range, verified it compiled, then added a 't' to the end of `front`. With `models` I got this for both UDA and static assert versions: /home/atila/coding/d/dlang/phobos/std/range/primitives.d(182): Error: template std.range.primitives.front cannot deduce function from argument types !()(Foo), candidates are: /home/atila/coding/d/dlang/phobos/std/range/primitives.d(2219): std.range.primitives.front(T)(T[] a) if (!isNarrowString!(T[]) && !is(T[] == void[])) /home/atila/coding/d/dlang/phobos/std/range/primitives.d(2247): std.range.primitives.front(T)(T[] a) if (isNarrowString!(T[])) /home/atila/coding/d/dlang/phobos/std/traits.d-mixin-6771(6771): Error: template instance std.range.primitives.checkInputRange!(Foo) error instantiating concepts.d(81): instantiated from here: models!(Foo, isInputRange) Failed: ["dmd", "-unittest", "-main", "-v", "-o-", "concepts.d", "-I."] With `static assert(isInputRange!Foo)`, I get this: concepts.d(87): Error: static assert (isInputRange!(Foo)) is false Failed: ["dmd", "-unittest", "-main", "-v", "-o-", "concepts.d", "-I."] I prefer the first one. How about you? Atila
Certainly the first one. -- Dmitry Olshansky
