Say that I have a void*
containing a pointer to an unknown class
. I want to use dynamic_cast
to do run-time checking on the type of cl
As I understand it you want a polymorphic object but no common base class.
There is already a fairly standard idiom for this - it's called boost::any
.
A boost::any
carries your object plus some type information. The interface allows you to query the type and to attempt to cast the any to the type you're looking for.
http://www.boost.org/doc/libs/1_59_0/doc/html/any.html