Proposal: static template(fail)

Gregor Richards Richards at codu.org
Thu Dec 13 11:38:28 PST 2007


BCS wrote:
> Reply to Janice,
> 
>> I would like to propose a new statement:
>>
>> static template(fail);
>>
>> which causes a compile-time substitution failure. And remember: SFINAE
>> - Substitution Failure Is Not An Error
>>
>> Let me give you an example:
>>
>> struct S(T)
>> {
>> static if(isFloatingPoint!(T))
>> {
>> /*...*/
>> }
>> else static if(passesSomeVeryComplicatedTest!(T))
>> {
>> /*...*/
>> }
>> else
>> {
>> static template(fail); // SFINAE
>> }
>> }
>> This has advantages over old-style specialisation.
>>
> 
> vote++
> 
> either for the "static template(fail)" or "T:if(exp)" form
> 
> 

static template(fail) seems a bit more general purpose so probably 
better, but the syntax makes me go "uhhh, what?" I think a different 
syntax would be good, but the idea is sound.

  - Gregor Richards



More information about the Digitalmars-d mailing list