digitalmars.D.bugs - [Issue 930] New: Templates inside templates used as mixins
- d-bugmail puremagic.com (33/33) Feb 03 2007 http://d.puremagic.com/issues/show_bug.cgi?id=930
- d-bugmail puremagic.com (27/27) Feb 04 2007 http://d.puremagic.com/issues/show_bug.cgi?id=930
http://d.puremagic.com/issues/show_bug.cgi?id=930
Summary: Templates inside templates used as mixins
Product: D
Version: 1.004
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla digitalmars.com
ReportedBy: wbaxter gmail.com
The following should work I believe, but apparently the type from the outer
template does not get propagated to the inner template.
It does work if the 'T' line is removed.
----
template ATemplate(T) {
template ATemplate() {
void foo() {
T x = 2; // this line causes an error
printf("Hi\n");
}
}
}
class TheClass(alias MixIt)
{
mixin MixIt;
}
void main() {
auto val = new TheClass!(ATemplate!(int));
val.foo();
}
--
Feb 03 2007
http://d.puremagic.com/issues/show_bug.cgi?id=930
wbaxter gmail.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |minor
Addendum - At least for my purposes, it turns out this can be handled by using
templated static structs instead of mixins:
struct ATemplate(T) {
static:
T svar = 99;
void foo() {
T x = 2; // this line causes an error
printf("Hi\n");
}
}
class TheClass(MixIt)
{
MixIt mix;
}
void main() {
auto val = new TheClass!(ATemplate!(int));
val.mix.foo();
}
----
This isn't holding me up in any way now, so downgrading to minor.
--
Feb 04 2007








d-bugmail puremagic.com