digitalmars.D.learn - Bug or intended?
- rsw0x (17/17) Feb 06 2016 I was playing around with alias templates and came across this, I
- Kagamin (1/1) Feb 06 2016 I'd say support for this scenario is not implemented yet.
- Marc =?UTF-8?B?U2Now7x0eg==?= (3/3) Feb 07 2016 The specification doesn't list (non-static) members a valid
- cy (8/25) Feb 08 2016 I think the "alias C c" you pass actually must be a value "c" of
I was playing around with alias templates and came across this, I
reduced it to:
---
struct A(alias C c){
auto foo(){
return c.i;
}
}
struct B{
C c;
A!c a;
}
struct C{
int i;
}
---
It gives me a "need 'this' for 'i' of type 'int'" error.
Feb 06 2016
I'd say support for this scenario is not implemented yet.
Feb 06 2016
The specification doesn't list (non-static) members a valid template alias parameters: http://dlang.org/spec/template.html#TemplateAliasParameter
Feb 07 2016
On Saturday, 6 February 2016 at 14:15:04 UTC, rsw0x wrote:
I was playing around with alias templates and came across this,
I reduced it to:
---
struct A(alias C c){
auto foo(){
return c.i;
}
}
struct B{
C c;
A!c a;
}
struct C{
int i;
}
---
It gives me a "need 'this' for 'i' of type 'int'" error.
I think the "alias C c" you pass actually must be a value "c" of
some sort. A!c would have to produce a different A struct, for
every c value. (as opposed to A!C which works fine.) So, if you
made B with a C with an i = 23, then you'd have an A!(23) and if
you made another one with i = 42, you'd have an A!(42).
That doesn't seem very useful, for general integers. Maybe if it
was an enum of finite, limited size it'd make sense.
Feb 08 2016









Kagamin <spam here.lot> 