Click here to Skip to main content
15,440,341 members

Comments by Sebastian Krysmanski (Top 5 by date)

Sebastian Krysmanski 10-Feb-12 4:37am View     CRLF
1. RTTI has nothing to do with virtual methods. 2. It's just an example that's not meant to be complete. It's stripped down to show the essential code. 3. "equals()" compares whether two instances (not types) are the same. The comparison isn't shown in the example (as it depends on the class' implementation - again, it's just an example). However, if the types are different, the instances can't be the same. 4. That's a good point.
Sebastian Krysmanski 8-Feb-12 3:15am View    
Unfortunately my code didn't allow for the base class to have a template parameter. This is why I "invented" my solution.
Sebastian Krysmanski 8-Feb-12 3:13am View    
Is this faster than my method? It is surely safer, but my goal was to have a fast solution.
Sebastian Krysmanski 8-Feb-12 3:12am View    
This only works if the base class (which is missing in your example) knows the template parameter type(s). In my example, however, this isn't the case and is actually the point of the whole tip.
Sebastian Krysmanski 8-Feb-12 3:09am View    
I should have written that this is supposed to be a very fast method of comparing types in cases where you have complete control over the implementation of all classes that are inheriting from BaseClass (like with private classes). Of course you can completely break this thing by not correctly overloading "classId()" but again, this method was meant to be fast and not to be dummy-safe.