constraints,template specialization,drop IFTI
Max Samukha
spambox at d-coding.com
Wed Jul 15 11:57:29 PDT 2009
On Wed, 15 Jul 2009 20:00:40 +0200, BLS <windevguy at hotmail.de> wrote:
>Jarrett Billingsley wrote:
>> On Wed, Jul 15, 2009 at 1:42 PM, BLS<windevguy at hotmail.de> wrote:
>>> Quote : "
>>> Constraints are not involved with determining which template is more
>>> specialized than another. "
>>
>> Well that is *completely* lame. I would have expected
>>
>> template Foo(int N : 5)
>>
>> to be sugar for
>>
>> template Foo(int N) if(N == 5)
>>
>> Why *isn't* that the case?
>
>Tu me demande ? Pas d' idee. ..have to ask the gurus
And template oveloading with refined concepts is not supported, which
makes constraints less useful than C++'s concepts:
// InputRange concept
template isInputRange(T)
{
....
}
// Refinement of InputRange concept
template isForwardRange(T)
{
enum isForwardRange = isInputRange!T && ....;
}
void foo(T)(T r) if (isInputRange!T)
{
}
void foo(T)(T r) if (isForwardRange!T)
{
}
void bar()
{
ForwardRange fr;
InputRange ir;
foo(fr);
foo(ir);
}
The above doesn't compile, of course. The limitation can be worked
around in a number of graceless ways but claiming that D's constraints
are superior to C++ concepts seems to be premature.
More information about the Digitalmars-d
mailing list