template specialization and template mixin
Jack Applegame
japplegame at gmail.com
Thu May 16 05:07:01 PDT 2013
This code compiles , as expected
struct A {
void func(string s : "foo")() {
pragma(msg, "func for foo");
}
void func(string s)() {
pragma(msg, "func for others: " ~ s);
}
}
void main() {
A a;
a.func!"foo"();
a.func!"bar"();
}
Why this doesn't compile?
mixin template M() {
void func(string s)() {
pragma(msg, "func for others: " ~ s);
}
}
struct A {
mixin M;
void func(string s : "foo")() {
pragma(msg, "func for foo");
}
}
void main() {
A a;
a.func!"foo"();
a.func!"bar"(); // Error
}
More information about the Digitalmars-d-learn
mailing list