On 03/29/2012 01:51 PM, Tove wrote:
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);
}
Some uses of the 'is' expression have been the most magical (read:
difficult) part of D for me. :) I am still not sure that I understand it
correctly. ;)
http://dlang.org/expression.html#IsExpression
Ali