Is it safe to use 'is' to compare types?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Mar 8 14:34:05 PST 2016


On 3/8/16 3:26 PM, Yuxuan Shui wrote:
> On Monday, 7 March 2016 at 16:13:45 UTC, Steven Schveighoffer wrote:
>> On 3/4/16 4:30 PM, Yuxuan Shui wrote:
>>> On Friday, 4 March 2016 at 15:18:55 UTC, Steven Schveighoffer wrote:
>>>> [...]
>>>
>>> Thanks for answering. But I still don't understand why TypeInfo would
>>> need to be allocated. Aren't typeid() just returning references to the
>>> __DxxTypeInfo_xxxx__initZ symbol?
>>
>> You misunderstood, I meant the typeinfo *for* an allocated object, not
>> that the typeinfo was allocated.
>>
>> In some cases, 2 different objects allocated from different libraries
>> (usually DLL-land) may reference TypeInfo from different segments,
>> even though the TypeInfo is identical.
>>
> Hmm... Does that mean each DLL will have their own TypeInfo symbols for
> the same type?

I don't know the exact circumstances. I think the answer is both yes and 
no, depending on the situation :)

But I know this is the reason for the string comparison.

-Steve


More information about the Digitalmars-d-learn mailing list