2 little enigmas with is & Unqual!

vincent picaud vincent.picaud at laposte.net
Wed Dec 1 07:03:57 PST 2010


spir Wrote:

> Hello,
> 
> 1. Why isn't Unqual!(char) == char?
>     writeln( is( Unqual!(typeof('c')) == char ) );	// false
>     writeln( is( Unqual!(char) == char ) );		// false
>     writeln( is( char == char ) );			// true!
> (dmd v2.049)
> 

Using GCD 4.3.5 ( more precisely on Linux/Debian )

    writeln( is( Unqual!(typeof('c')) == char ) );       
    writeln( is( Unqual!(char) == char ) );                
    writeln( is( char == char ) );                        

returns 

true
true
true

as expected

> 2. Why cannot one write "assert(is(Unqual(t1) == t2))"?
>     assert( is( char == char ) );			// OK
>     assert( is( Unqual!(char) != char ) );		// compile Error
>     assert( is( Unqual!(typeof('c')) != char ) );	// compile Error
> (is() gets on my nerves ;-)
> 

not sure of that, but I think "is" is a compile time feature, hence you must write
static  assert( is( char == char ) );			// OK
static  assert( is( Unqual!(char)  == char ) );		// OK
static  assert( is( Unqual!(typeof('c'))  == char ) );	// Ok

hope this can help....

> Denis
> -- -- -- -- -- -- --
> vit esse estrany ☣
> 
> spir.wikidot.com
> 



More information about the Digitalmars-d-learn mailing list