SFINAE

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Oct 5 15:52:18 PDT 2008


Jason House wrote:
> Now that we're all talking about templates and Andrei is participating on
> this list, I figure it's a good time to bring this topic up again.
> 
> (brief background: SFINAE = substitution failure is not an error.  Commonly
> used when selecting which templated definition to apply.  Most uses in C++
> are tricks to determine info available in D is expressions)
> 
> SFINAE causes debugging nightmares with template based code when a
> specialization fails to compile as expected.  When I challenged people in
> the past to provide real examples of template code that would require
> SFINAE in D, nobody could come up with one.  The template declaration and
> constraints in D seem to be enough.
> 
> I think we should try removing SFINAE from D 2.x while it's still considered
> experimental/alpha.  I expect a lack of SFINAE to make the compiler simpler
> and ensure D preserves its fast compile times.
> 
> If it does turn out that SFINAE does provide unique functionality, I think
> it may be better to enhance existing generic programming techniques than to
> keep SFINAE.  The further SFINAE gets pushed out of normal use (through
> constraints and detailed type declarations), the more of a corner case
> SFINAE becomes.  The more this happens, the more this "feature" will bite
> developers instead of helping them.
> 
> PS: This is basically a rehash of what I typed in
> http://d.puremagic.com/issues/show_bug.cgi?id=1951
> 
> It's also based on the past newsgroup thread at
> http://digitalmars.com/d/archives/digitalmars/D/SFINAE_is_Evil_67995.html

I think conditional templates obviate most, if not all, of the need for 
sfinae. There need to be some more steps taken, most importantly 
unification of regular functions with template functions.

Andrei at home



More information about the Digitalmars-d mailing list