"Un-const"-ing a type in D
I'm trying to write a template named Unconst
that would turn something like const(int)
into int
; in other words
Unconst!(const(int))
should give
int
I can't figure out how, though... any creative ideas for making this work?
(Extension: It would be great if the method could be extended to also work with shared
and other type construct开发者_运维知识库ors.)
Never mind, I found the answer myself...
template Unconst(T)
{
static if (is(T U == const U))
alias U Unconst;
}
精彩评论