<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.2.2">
</HEAD>
<BODY>
Run this code:<BR>
<BR>
class PP {}<BR>
<BR>
void what(T)(T val)<BR>
{<BR>
static if (is(T == int)) writeln ("T == int");<BR>
static if (is(T == const(int))) writeln ("T == const(int)");<BR>
static if (is(T : int)) writeln ("T : int");<BR>
static if (is(T == PP)) writeln ("T == PP");<BR>
static if (is(T == const(PP))) writeln ("T == const(PP)");<BR>
static if (is(T : PP)) writeln ("T : PP");<BR>
}<BR>
<BR>
void main(string[] args)<BR>
{<BR>
<BR>
const int aa = 10;<BR>
int ab;<BR>
<BR>
const PP ba = new PP;<BR>
PP bb = new PP;<BR>
<BR>
writeln("- Testing const(int)");<BR>
what(aa);<BR>
writeln();<BR>
<BR>
writeln("- Testing int");<BR>
what(ab);<BR>
writeln();<BR>
<BR>
writeln("- Testing const(PP)");<BR>
what(ba);<BR>
writeln();<BR>
<BR>
writeln("- Testing PP");<BR>
what(bb);<BR>
writeln();<BR>
<BR>
return;<BR>
}<BR>
<BR>
It says:<BR>
<BR>
- Testing const(int)<BR>
T == const(int)<BR>
T : int<BR>
<BR>
- Testing int<BR>
T == int<BR>
T : int<BR>
<BR>
- Testing const(PP)<BR>
T == const(PP)<BR>
<BR>
- Testing PP<BR>
T == PP<BR>
T : PP<BR>
<BR>
<BR>
So:<BR>
const(int) : int <-- true<BR>
const(PP) : PP <-- false<BR>
<BR>
Is this behaviour correct?<BR>
<BR>
And how can I check if T is of a certain class ignoring consts (and avoiding double checks)?<BR>
<BR>
<BR>
<BR>
<BR>
</BODY>
</HTML>