C++0x Concepts - Dead?
Walter Bright
newshound1 at digitalmars.com
Thu Jul 16 15:14:24 PDT 2009
aarti_pl wrote:
> Walter Bright pisze:
>> aarti_pl wrote:
>>> My proposal would make meta programing in D much more intuitive
>>> (because of using rules - not bunch of corner cases as it is today).
>>> Unfortunately almost no one from NG commented on that...
>>
>> Thank you, but I don't see in your proposal a method that can:
>>
>> 1. instantiate templates only if a value argument is prime or odd.
>>
>> 2. instantiate templates only on a type which supports addition and
>> has the method foo.
>>
>> Note that C++ Concepts could do (2) but could not do (1).
>
> ad.1
>
> template normalizedType((T U N : U[N=size_t]) && (N & 1))
>
> As it is stated in proposal commas are only syntax sugar for more
> general form with '&&'.
How do you distinguish a type from an expression?
> ad.2.
>
> This case is in fact the same as 1. Because of the fact that A, B, C <=>
> A && B && C, you can create expressions as you want just using second
> form with logical operators. In this case you should just use proper
> compile time reflection mechanism in D to get information about type
> properties.
class C {
int opAdd(C);
}
How would I write the parameter to accept any type that supports
addition? I want to support int, float, C, etc., without having to
exhaustively enumerate them.
More information about the Digitalmars-d-announce
mailing list