Andreas Schallenberg <[EMAIL PROTECTED]> writes:

> is there any way to make g++ (preferably) report dynamic_cast
> statements that are unnecessary?  Example:
>
> class A{...};
> class B : public A {...};
> class C : public B {...};
> ...
> void myFunc(C * obj)
> {
>   // redundant one...
>   ... = dynamic_cast<C*>(obj);
>   // ...redundant two
>   ... = dynamic_cast<B*>(obj);
> }

Not that I know of.

You could of course write a little function template that
- invokes dynamic_cast if source and destination types are different
- produces a compiler error if both types are equal

and use that function template instead of dynamic_cast.
_______________________________________________
help-gplusplus mailing list
help-gplusplus@gnu.org
http://lists.gnu.org/mailman/listinfo/help-gplusplus

Reply via email to