question...

Marcin Kuszczak aarti_please_no at spam_interia.pl
Wed Jan 9 12:49:21 PST 2008


Aziz K. wrote:

>> Above is ok. for me currently, but I have different problem:
>>
>> void main() {
>> class A {}
>> static assert(is( typeof(new A) == typeof(A)) ); // 1
>> static assert(is( typeof(new int*) == typeof(int*) )); // 2
>> }
>>
>> First assert compiles, but the second one not.
> 
> The second one doesn't compile because it isn't syntactically correct.
> The error lies in "typeof(int*)". You are feeding the typeof expression
> with a "Type" ("int*"), but it expects an "Expression" (like "int.max",
> "new A", "2+5i" etc.) The purpose of typeof is to evaluate (without
> side-effects) the expression contained in it and return the type of that.
> 
> Regards,
> Aziz

Thanks but explanation. But I think that somethink is wrong here anyway.
Please see first example. 'A' is also not expression, but it compiles
properly. Maybe it would not be a big problem to extend typeof in such a
way that it can accept types also.

-- 
Regards
Marcin Kuszczak (Aarti_pl)
-------------------------------------
Ask me why I believe in Jesus - http://www.zapytajmnie.com (en/pl)
Doost (port of few Boost libraries) - http://www.dsource.org/projects/doost/
-------------------------------------



More information about the Digitalmars-d-learn mailing list