Proposal: static template(fail)

Janice Caron caron800 at googlemail.com
Fri Dec 14 11:47:37 PST 2007


On 12/14/07, BCS <ao at pathlink.com> wrote:
> Example (each case maintained independently)

I don't know if this is reasonable, because you've got multiple
different versions of Foo(T). But maybe...


> template Foo(T)
> {
>   static if(/*logic 1 on T*/)
>     /* code */
>   else
>     template(fail);
> }
>
> template Foo(T)
> {
>   static if(/*logic 2 on T*/)
>     /* code */
>   else
>     template(fail);
> }
>
> template Foo(T)
> {
>   /* general case code */
> }

My feeling is, you could recode that as

template Foo(T)
{
  static if(/*logic 1 on T*/)
    /* code */
  else static if(/*logic 2 on T*/)
    /* code */
  else
    /* general case code */
}

without needing either specialisation or template(fail). (But there
are other cases where it /would/ be useful, obviously).



More information about the Digitalmars-d mailing list