I don't think the exception handling is any good here. There's nothing in the try block that could throw a bad_cast, AFAIK - the only cast there is a hard C-style cast, which doesn't throw.