I would do the virtual function approach like this:  
https://coliru.stacked-crooked.com/a/0f0b68334eaa4880

Tangentially, it's best to avoid reinterpet_cast when possible.  Casting from 
base to derived class pointer/reference can be done with static or dynamic 
cast.  Dynamic cast is best in this case, because it will throw an exception if 
you accidentally compare two different derived types, whereas using static cast 
would result in undefined behavior.  With multiple inheritance, 
reinterpret_cast can actually be wrong for casting from base to derived, 
because the conversion requires subtracting an offset.

Aside from possible exceptions, there's the obvious addition overhead with 
virtual functions.

[ Full content available at: https://github.com/apache/trafficserver/pull/4262 ]
This message was relayed via gitbox.apache.org for [email protected]

Reply via email to