
10 Jan
2008
10 Jan
'08
2:35 p.m.
dizzy wrote:
The final (best?) solution I came with now is using RTTI. RTTI's typeid() is by design non-intrusive (actually the way it is implemented by the compiler is intrusive but it happens anyway for any polymorphic type so why not use it) and it does not have any of the problems listed above, the implementation is "small enough" that I can include it here:
If I understand correctly, your implementation is O(n) with n = size(typelist), right? The advantage of virtual calls is that they're O(1), no matter how big the hierarchy. Though if that is a problem in the real world is a different question. How big are visited class hierarchies usually? Sebastian Redl