"SFINAE is Evil"
Jason House
jason.james.house at gmail.com
Fri Mar 21 20:09:11 PDT 2008
It looks like your first compiler error is correct... There is no function.
> Jason House wrote:
> > SFINAE - Substitution failure is not an error
> >
> > This post is all about templates and their static if counterparts. With the
> > enhanced expressiveness of D, is there a need for SFINAE from C++?
>
> Here's a classic example of how SFINAE makes things hard. Look at the
> code below. You'd expect the static assert to fail, right? Give you an
> error message at the right location, and point you towards your bug?
>
> Nope.
>
> BEGIN CODE
> import std.stdio;
>
> template foo(TPL...)
> {
> static assert(false);
> }
>
> void main()
> {
> int i;
> foo!(i)();
> }
> END CODE
>
> Here's what the compiler actually says:
> sfinae.d(3): template sfinae.foo(TPL...) is not a function template
> sfinae.d(11): template sfinae.foo(TPL...) cannot deduce template
> function from argument types !(i)()
>
> Not even a mention of the real problem. Now imagine that you are using
> non-trivial templates!
>
> Russ
More information about the Digitalmars-d
mailing list