[C++-sig] How to check if object is of specific type?

Stefan Seefeld seefeld at sympatico.ca
Tue Feb 19 15:25:27 CET 2008


Marcus Jannes wrote:
> Hello,
> 
> I want to do something similar to the PyObject_TypeCheck() in boost.python. How can i check the type of an object that is passed to a function?

object o = ...;
extract<expected_type> e(o);
if (e.check())
{
   expected_type a = e();
   // now use 'a'
}

HTH,
		Stefan

-- 

       ...ich hab' noch einen Koffer in Berlin...



More information about the Cplusplus-sig mailing list