Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
July 03, 2002 rtti? | ||||
---|---|---|---|---|
| ||||
(This surely has been already told. I remember I have read about it somewhere, but I don't remember where... I apologize.) What's the D sintax for RTTI? I tried if(instance.typeinfo === Class.typeinfo) {/*...*/} but this doesn't work. I tried if(instance.classinfo === Class.classinfo) {/*...*/} but this generates an internal error. How should I write the D equivalent of the following C++ code? #include <typeinfo> class Class {} instance; if(typeid(instance) == typeid(Class)) {/*...*/} Thanks in advance for helping me! Dario |
July 04, 2002 Re: rtti? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | Dario wrote: > (This surely has been already told. I remember I have read about it > somewhere, but I don't remember where... I apologize.) We discussed it a few weeks ago, but your problem is new. > What's the D sintax for RTTI? I tried > if(instance.typeinfo === Class.typeinfo) {/*...*/} > but this doesn't work. I tried > > if(instance.classinfo === Class.classinfo) {/*...*/} > but this generates an internal error. This is correct and should work. Could you boil it down to the smallest amount of code that can cause the internal error and then post that? |
July 04, 2002 Re: rtti? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons Attachments: | > > (This surely has been already told. I remember I have read about it somewhere, but I don't remember where... I apologize.) > We discussed it a few weeks ago, but your problem is new. > > What's the D sintax for RTTI? I tried > > if(instance.typeinfo === Class.typeinfo) {/*...*/} > > but this doesn't work. I tried > > if(instance.classinfo === Class.classinfo) {/*...*/} > > but this generates an internal error. > This is correct and should work. Could you boil it down to the smallest amount of code that can cause the internal error and then post that? This compiles good but emits a runtime error: Error: Object 00690D70 |
July 04, 2002 Re: rtti? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Dario | Dario wrote:
>>>(This surely has been already told. I remember I have read about it
>>>somewhere, but I don't remember where... I apologize.)
>>>
>
>>We discussed it a few weeks ago, but your problem is new.
>>
>
>>>What's the D sintax for RTTI? I tried
>>>if(instance.typeinfo === Class.typeinfo) {/*...*/}
>>>but this doesn't work. I tried
>>>if(instance.classinfo === Class.classinfo) {/*...*/}
>>>but this generates an internal error.
>
>>This is correct and should work. Could you boil it down to the smallest
>>amount of code that can cause the internal error and then post that?
>
> This compiles good but emits a runtime error:
> Error: Object 00690D70
All references are initialised to null, so you're dereferencing a null pointer there. Putting a "a = new AAA;" before that line should make it work, although you may need to add a constructor.
|
July 04, 2002 Re: rtti? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Burton Radons | ARGH! I'm so stupid that I forgot that! Thank you Burton! =] Dario |
Copyright © 1999-2021 by the D Language Foundation