Overlapping functionality: IFTI, templates, is-expressions

Don Clugston dac at nospam.com.au
Thu Mar 20 02:40:40 PDT 2008


Russell Lewis wrote:
> Jason House wrote:
>> #2 (SFINAE) I know from past discussions that C++ programmers hold 
>> this very near and
>> dear to their heart.  Personally, it seems like a back door to long
>> compilation times.  I don't have any problem with enforcing criteria for
>> templates to be defined up front, but I'm certain others don't agree with
>> me.  Does the loss of SFINAE make templates too close to generics?  I 
>> know
>> C# will refuse to compile code if the up-front criteria for a generic 
>> type
>> isn't specific enough.
> 
> FYI: SFINAE is "Substitution Failure Is Not An Error".  See Wikipedia.
> 
> I thought about this some more, wondering why C++ programmers would have 
> come to this conclusion.  I now think it likely that they did this 
> specifically because they didn't have static if() and is-expressions. If 
> you don't have those two tools, then the only thing you can do is to run 
> ahead into something, and hope it works...but if it doesn't work, you 
> provide a more general alternative.
> 
> Is it possible that SFINAE was a hack to get around C++'s lack of 
> compile-time features?  A hack that we can now dispense of?

Possibly. It's hard to come up with code that looks cleaner with specialisation 
and SFINAE than it does with a static if.
My experience was similar to yours -- I stopped using SFINAE.



More information about the Digitalmars-d mailing list