From: Darin Adler (darin_at_[hidden])
Date: 1999-09-19 23:39:17
>> - polymorphic_downcast<> is poor name because it's for upcasts too
>> + change name to polymorphic_static_cast<>
> Disagree. It's only for what I designed it for ;)
> Why would you use it for upcasts when implicit conversion does that
Oops! You're right! Sorry; I got confused.
Aside: It would be nice if a future implementation of polymorphic_downcast
contained a compile-time assertion that Derived is derived from Base, since
neither the static_cast nor the dynamic_cast requires that.
>> - some users of casts.hpp may prefer asserts instead of exceptions
>> + make version of casts.hpp that can do asserts instead of exceptions
>> (use two different namespaces and determine which to import into boost with
>> a compile-time switch; exception version should be default)
> Now you're talking about the numeric casts, right?
For someone that finds assertions that are removed from the final product
distasteful and prefers exceptions, I think that polymorphic_downcast<>
should be a synonym for polymorphic_cast<>. I don't see a major reason that
the runtime check should be elided in that particular case if you're a fan
of keeping in the runtime checks, even though dynamic_cast<> is more
expensive than static_cast<>.
Moving on, I'd typically use polymorphic_cast<> when I would otherwise use
dynamic_cast<>, but in cases where I know that the cast will succeed. I'd
prefer an assert to a runtime check just as I would in numeric casts, at
least for some projects.
So my intent there is to talk about all the casts.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk