constraints,template specialization,drop IFTI

Daniel Keep daniel.keep.lists at gmail.com
Wed Jul 15 10:16:17 PDT 2009



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;
}

> ...
> 
> A smarter implementation will probably support tuple based pattern
> matching.

Huh?  Isn't this how template matching works anyway; match a given
argument tuple against the available templates?

Lastly, what's that in the subject about dropping IFTI?  I seriously
hope you're joking about that.



More information about the Digitalmars-d mailing list