Where does "U" in Rebindable.Rebindable come from?

Tove tove at fransson.se
Thu Mar 29 13:51:12 PDT 2012


On Thursday, 29 March 2012 at 20:15:43 UTC, simendsjo wrote:
> If you look at the struct, it uses the type U in, among others, 
> the union.
>
> The only place I could see U referenced is in the first static 
> if, but I cannot recreate this behavior:
> void main() {
>     static if(is(int X == const(U), U))
>     {
>     }
>     else
>     {
>         static assert(is(typeof(U))); // false, U not defined
>     }
> }
>

magic pattern matching...

import std.stdio;

void main()
{
     static if(is(int x == const(U), U))
       writeln("Mutable: " ~ U.stringof);
     else static if(is(const int x == const(U), U))
       writeln("Const: " ~ U.stringof);
}



More information about the Digitalmars-d-learn mailing list