Walter Bright wrote:
Christian Kamm wrote:
Christian Kamm wrote:
Is there a difference between
template Foo(T : U) {} and
template Foo(T) if(is(T : U)) {} ?
Walter Bright wrote:
Yes. Constraints determine the list of candidate template declarations,
but do not participate in the partial ordering of candidates to
determine the 'best' match.
Thanks for the explanation!
I expect the reason is that for constrained templates it is impossible
to determine whether all valid template arguments for one would lead
to a valid instantiation of another?
That's a good technical reason, but I also felt that the current way
just made intuitive sense.
The current Template specialization implementation is doing a best fit
search anyway, so why constraints are not able to use the same mechanism. ?
So, instead of IFTI we should have EFTI*, driven by constraints.
*The name is rather confusing so "fuzzy templates" are probably better.
bearophile brings in several times Scala/OCAML like pattern matching.
Why not using that for constraints ?
IMO the current D constraints implementation is nice and easy, but I
thing there is much more hidden power in that idea.
Thanks for ignoring my ignorance..