identifying the type

Posted by Gokul on Stack Overflow See other posts from Stack Overflow or by Gokul
Published on 2010-04-21T14:46:41Z Indexed on 2010/04/21 14:53 UTC
Read the original article Hit count: 332

Filed under:
|
|

Hi, In my application, there is a inheritance hierarchy in which only the classes that are at the end of the inheritance chain are non-abstract classes. Also there is some usage of boost::variant. I want to write a function which takes a pointer and a Type and says whether the object belongs to that type.

For example

template< typename Type, bool TypeisAbstract, typename ptrType >
bool checkType( ptrType* t)
{
    return ( typeid(*t) == typeid(Type) );
}

template< typename Type, typename ptrType >
bool checkType<Type, true, ptrType>( ptrType* t)
{
    return ( dynamic_cast<Type*>(t) != NULL );
}

Now if there is a boost variant, i want to find out whether the boost variant stores that particular type. Can someone help me with that?

Thanks, Gokul.

© Stack Overflow or respective owner

Related posts about c++

Related posts about rtti