Thread overview | ||||||
---|---|---|---|---|---|---|
|
August 09, 2007 Template | ||||
---|---|---|---|---|
| ||||
I tried to use common c++ technique in D: class Super (alias T) { alias T.Type A; >>> Error: no property 'Type' for type xxx.Sub' void test() { alias T.Type B; >>> ok } } class Sub : Super !(Sub) { alias int Type; } alias A fails to compile although alias B inside scope of function is ok. Is that intended? What is the idea behind that? Vladimir |
August 09, 2007 Re: Template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | Vladimir wrote:
> I tried to use common c++ technique in D:
>
> class Super (alias T)
> {
> alias T.Type A; >>> Error: no property 'Type' for type xxx.Sub'
>
> void test()
> {
> alias T.Type B; >>> ok
> }
> }
>
> class Sub : Super !(Sub)
> {
> alias int Type;
> }
>
> alias A fails to compile although alias B inside scope of function is ok. Is that intended? What is the idea behind that?
I suspect it must have something to do with 'Sub' not being defined at the point where you're using it as a template parameter.
This compiles:
class Super (T)
{
alias T.Type A;
void test()
{
alias T.Type B;
}
}
class Temp
{
alias int Type;
}
class Sub : Super !(Temp)
{
alias int Type;
}
void main() {}
Incidently, notice that I'm not using 'alias' in my Super template. It doesn't seem to be required.
Regan
|
August 09, 2007 Re: Template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Regan Heath | Regan Heath Wrote:
> Vladimir wrote:
> > I tried to use common c++ technique in D:
> >
> > class Super (alias T)
> > {
> > alias T.Type A; >>> Error: no property 'Type' for type xxx.Sub'
> >
> > void test()
> > {
> > alias T.Type B; >>> ok
> > }
> > }
> >
> > class Sub : Super !(Sub)
> > {
> > alias int Type;
> > }
> >
> > alias A fails to compile although alias B inside scope of function is ok. Is that intended? What is the idea behind that?
>
> I suspect it must have something to do with 'Sub' not being defined at the point where you're using it as a template parameter.
>
> This compiles:
>
> class Super (T)
> {
> alias T.Type A;
>
> void test()
> {
> alias T.Type B;
> }
> }
>
> class Temp
> {
> alias int Type;
> }
>
> class Sub : Super !(Temp)
> {
> alias int Type;
> }
>
> void main() {}
>
> Incidently, notice that I'm not using 'alias' in my Super template. It doesn't seem to be required.
>
> Regan
Thanks for quick response. Your workarrond is suitable. I wonder should it be considered as a bug and subject for future fix?
|
August 09, 2007 Re: Template | ||||
---|---|---|---|---|
| ||||
Posted in reply to Vladimir | Vladimir wrote:
> Regan Heath Wrote:
>
>> Vladimir wrote:
>>> I tried to use common c++ technique in D:
>>>
>>> class Super (alias T)
>>> {
>>> alias T.Type A; >>> Error: no property 'Type' for type xxx.Sub'
>>>
>>> void test()
>>> {
>>> alias T.Type B; >>> ok
>>> }
>>> }
>>>
>>> class Sub : Super !(Sub)
>>> {
>>> alias int Type;
>>> }
>>>
>>> alias A fails to compile although alias B inside scope of function is ok. Is that intended? What is the idea behind that?
>> I suspect it must have something to do with 'Sub' not being defined at the point where you're using it as a template parameter.
>>
>> This compiles:
>>
>> class Super (T)
>> {
>> alias T.Type A;
>>
>> void test()
>> {
>> alias T.Type B;
>> }
>> }
>>
>> class Temp
>> {
>> alias int Type;
>> }
>>
>> class Sub : Super !(Temp)
>> {
>> alias int Type;
>> }
>>
>> void main() {}
>>
>> Incidently, notice that I'm not using 'alias' in my Super template. It doesn't seem to be required.
>>
>> Regan
>
> Thanks for quick response. Your workarrond is suitable. I wonder should it be considered as a bug and subject for future fix?
I think you should post it to bugzilla, if it's a bug it will get dealt with eventually, if not it will get dealt with eventually. :)
Regan
|
Copyright © 1999-2021 by the D Language Foundation