Strange template alias behaviour
Simen Kjaeraas
simen.kjaras at gmail.com
Sun Nov 18 13:38:30 PST 2012
On 2012-05-18 17:11, Maxim Fomin <maxim at maxim-fomin.ru> wrote:
> Changing template parameter to Bar.f or bar.f affects value of
> bar.f.data. Seems to be a bug.
It's a bug. Further reduction:
import std.stdio;
mixin template Foo() {
string data = "default";
}
struct Bar {
mixin Foo f;
}
string get_data(alias unused, T)(T obj) {
return obj.f.data;
}
void main() {
Bar bar = Bar("");
writeln(get_data!Bar(bar));
writeln(get_data!(Bar.f)(bar)); // This line fucks things up.
assert( get_data!Bar(bar) == get_data!(Bar.f)(bar) );
}
Note also that moving the marked line above the line before it
makes the assert pass. However, the writelns will both print the
wrong value ("default").
--
Simen
More information about the Digitalmars-d-learn
mailing list