basic types and alias
Steven Schveighoffer
schveiguy at yahoo.com
Fri Feb 17 06:10:56 PST 2012
On Sun, 12 Feb 2012 15:44:22 -0500, Walter Bright
<newshound2 at digitalmars.com> wrote:
> On 2/12/2012 11:27 AM, Timon Gehr wrote:
>> alias int I; // OK
>> template T(alias I){}
>> mixin T!int; // NG
>>
>> Is there any reason why we should not get rid of this inconsistency as
>> fast as
>> possible? What does not accepting basic types as template alias
>> parameters buy
>> anyone?
>
> alias parameters accept symbols. Keywords are not symbols. To pass a
> type, just use template T(I).
Yeah, but types can be keywords, and types can be symbols. There are good
use cases to being able to alias int in a template.
This works:
// would have used typedef, but typedef is deprecated...
struct S
{
int ___val;
alias ___val this;
}
template T(alias I) {}
mixin T!S;
I don't see the reason to present such an obstacle.
You could ease the restriction to "you can alias only symbols or keywords
that could be aliased to symbols".
-Steve
More information about the Digitalmars-d
mailing list