Classes and class hierarchies
C.147
Use `dynamic_cast` to a reference type when failure to find the required class is considered an error
Reason
Casting to a reference expresses that you intend to end up with a valid object, so the cast must succeed. dynamic_cast will then throw if it does not succeed.
Example
std::string f(Base& b)
{
return dynamic_cast<Derived&>(b).to_string();
}
Enforcement
???