const-typed class does not have const members
eatingstaples at gmail.com
Fri Jan 21 16:09:31 PST 2011
The following code yields results as commented.
const A a = new A;
writeln(typeof(a).stringof); // const(A)
writeln(typeof(a.b).stringof); // const(int)
writeln((const A).stringof); // const(A)
writeln(typeof((const A).b).stringof); // int
Given this information, how do I work around this in templates? I'd like a
template which can type its params based on members of T, for instance:
void foo(T)(T x, typeof(T.member) y)
but this will yield non-const second parameters even if T is const. Help anybody?
More information about the Digitalmars-d-learn