Overlapping functionality: IFTI, templates, is-expressions
Jason House
jason.james.house at gmail.com
Thu Mar 20 06:02:52 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.
Sorry, I should have defined it in my post. That's what I get for thinking about too many things at once.
> 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.
Sounds right.
> 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?
I don't know if it's that simple. What if I want a specialization where T extends from two interfaces? I think the current syntax can handle simple stuff, but I don't know if it can go beyond that. Maybe some would argue the more complex cases should be done with static if anyway...
Personally, I wouldn't mind some kind of optional in clause for a templated definition that can do a few static asserts to force more complex conditions... I don't know what would be the best syntax for that.
More information about the Digitalmars-d
mailing list