constancy and template parameters in D2.009+
Christopher Wright
dhasenan at gmail.com
Thu Dec 13 11:12:30 PST 2007
Janice Caron wrote:
> I think the template idea actually works. You could implement it in
> std.typecons as
>
> template RemoveHeadConst(T) { alias T RemoveHeadConst; }
>
> It ought to work because the parameter has been expressed as (T), not
> (T:T), or my suggested (init T). If that works, one of the two
> problems is solved without /any/ modification to the language.
>
> That just leaves (1)...
Of course, if you say that the constness of parameters should always be
preserved, you'd get:
template RemoveHeadConst(T) {
static if (is (T : const(U), U)) {
alias U RemoveHeadConst;
} else {
alias T RemoveHeadConst;
}
}
It's really just a matter of which case will be more common.
More information about the Digitalmars-d
mailing list