"Un-const" - type type D

I am trying to write a template with a name Unconstthat will turn something like const(int)into int; in other words

Unconst!(const(int))

should give

int

I can’t understand how, though ... any creative ideas for creating this work?

(Extension: it would be great if this method could be extended to work with sharedother type constructors.)

+3
source share
1 answer

Nothing, I myself found the answer ...

template Unconst(T)
{
    static if (is(T U == const U))
        alias U Unconst;
}
+2
source

Source: https://habr.com/ru/post/1785830/


All Articles