<meta http-equiv="content-type" content="text/html; charset=utf-8">Hi Jan,<div><br></div><div>I think 'classof' should be virtual for isa<> and friends to work. In addition you can provide a static 'classof' for the same class that will speed up the cases like isa<A>(a) and isa<A>(b).<br>
<br></div><div>Regards,</div><div>Victor</div><br><div class="gmail_quote">On Wed, Aug 25, 2010 at 4:02 PM, Jan Bierbaum <span dir="ltr"><<a href="mailto:s3306700@inf.tu-dresden.de">s3306700@inf.tu-dresden.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi!<br>
<br>
I hope I'm not too OT with that question, but Clang makes extensive use<br>
of this mechanism so maybe somebody can help me.<br>
<br>
LLVM provides isa<>, cast<> and so on. Recently I tried to make use of<br>
this for my own class hierarchy, but failed.<br>
<br>
>From the documentation and examples in Clang's code I figured that the<br>
only thing to do was add a static method 'classof' to any involved class<br>
with a parameter that will match any parent class. Then inside this<br>
method do any checks necessary and return 'true' if the current instance<br>
is indeed of the type given.<br>
<br>
But when I do this I get 'true' for any 'isa<>' I try!?<br>
<br>
Attached is a small example that outputs the following:<br>
<br>
| $ ./a.out<br>
| isa<A>(a) = 1<br>
| isa<B>(a) = 1<br>
| isa<B>(b) = 1<br>
| isa<A>(b) = 1<br>
<br>
What I would expect instead is the second line to yield false/0, since a<br>
is an instance of class A which "is" no B.<br>
<br>
Can somebody please give me a hint on what I'm doing wrong?<br>
<br>
<br>
Regards, Jan.<br>
<br>_______________________________________________<br>
cfe-dev mailing list<br>
<a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
<br></blockquote></div><br>