Overlapping functionality: IFTI, templates, is-expressions

Jason House jason.james.house at gmail.com
Thu Mar 20 09:24:20 PDT 2008


Russell Lewis Wrote:

> Jason House wrote:
> >> 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.
> 
> Good idea!  But just to make things clear, let's make it an "SFINAE 
> block."  How about this definition:
> 
> BEGIN CODE
> 	template foo(PARAMS)
> 	sfinae
> 	{
> 		// any failures in this block of code will cause DMD to
> 		// silently try a different template specialization
> 	}
> 	body
> 	{
> 		// any failures in this block of code are hard failures
> 
> 		// ...but this block of code should be able to reference
> 		// symbols declared in the sfinae block
> 	}
> END CODE

Yes, that's exactly the kind of thing I'm thinking of.



More information about the Digitalmars-d mailing list