How to make stuff const in a template?
Janice Caron
caron800 at googlemail.com
Wed Nov 28 02:38:07 PST 2007
The following program gives unexptected results.
template MakeConst(T)
{
alias const(T) MakeConst;
}
void main()
{
alias float MF;
alias const(float) CF;
alias MakeConst!(MF) TF;
writefln(MF.stringof, ", ", typeid(MF));
writefln(CF.stringof, ", ", typeid(CF));
writefln(TF.stringof, ", ", typeid(TF));
}
It prints...
float, float
const float, const float
float, float
I would have expected the second and third lines to be identical. Why
aren't they?
More to the point, how can I create a template which turns a primitive
type T into a const(T)?
More information about the Digitalmars-d
mailing list