constraints,template specialization,drop IFTI

Ary Borenszweig ary at esperanto.org.ar
Wed Jul 15 10:20:04 PDT 2009


Daniel Keep wrote:
> 
> BLS wrote:
>> I have somehow the idea that D constraints and template specialization
>> should merge.
>> Guess what I want to say is that instead of accepting the  compiler
>> decision for template specialization  a constraints could be used for :
>> "I am not the one who is able to fulfill your needs.. try this template
>> instead."
>>
>> template Foo(int N)
>>         if ( ( N & 1 _else_ FooOdd!(int N)) )
>> {
>>     ...
>> }
> 
> Firstly, why not
> 
> template Foo(int N)
>     if( N&1 ) else FooOdd!N
> {
>     ...
> }
> 
> Secondly, why?  I mean, isn't this equivalent to:
> 
> template Foo(int N)
> {
>     static if( N&1 ) { ... }
>     else alias FooOdd!N Foo;
> }

And this?

template Foo(int N) if ((N & 1) != 0)
{
}

template Foo(int N) if ((N & 1) != 1)
{
}



More information about the Digitalmars-d mailing list