Go to the documentation of this file.00001
00009 #ifndef INSTANCEOF_HH
00010 #define INSTANCEOF_HH
00011
00012 #include<typeinfo>
00013
00014 namespace my_lib {
00015
00032 template<typename T, typename U>
00033 bool instanceof(const U& val){
00034 try{
00035 const T& test = dynamic_cast<const T&>(val);
00036 return true;
00037 }
00038 catch(std::bad_cast& e){
00039 return false;
00040 }
00041 }
00042
00043 }
00044
00045 #endif //INSTANCEOF_HH