opEquals default behaviour - poorly documented or am I missing something?

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Tue Nov 17 12:35:10 PST 2015


On 11/17/15 3:25 PM, user123ABCabc wrote:
> On Tuesday, 17 November 2015 at 19:44:36 UTC, Ali Çehreli wrote:
>>     if (typeid(a) == typeid(b)) return a.opEquals(b);
>
> Wow this is terrible to compare two objects in D. The line I quoted
> means that two TypeInfoClass are likely to be allocated, right ?

No, those are immutable stored in the data segment. Fetching them costs 
only doing the fetch of the class info pointer.

-Steve


More information about the Digitalmars-d-learn mailing list