Proposal: static template(fail)

Bill Baxter dnewsgroup at billbaxter.com
Thu Dec 13 12:02:00 PST 2007


Janice Caron wrote:
> 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.

All you need is *anything* that would generate an ordinary compiler 
error.  So actually your suggested syntax may /already/ work!

--bb



More information about the Digitalmars-d mailing list