On Mon, 2010-08-02 at 10:33 +0200, Anders Logg wrote: > On Sun, Aug 01, 2010 at 06:35:22PM +0100, Garth N. Wells wrote: > > On Sun, 2010-08-01 at 12:40 +0200, Florian Rathgeber wrote: > > > -----BEGIN PGP SIGNED MESSAGE----- > > > Hash: SHA1 > > > > > > Hi, > > > > > > When using GenericTensor::down_cast() for a tentative down cast it would > > > be helpful if it would throw std::bad_alloc (as any dynamic_cast would > > > do) > > > > Do you mean std::bad_cast? > > > > > instead of invoking dolfin::error. Currently you would have to catch > > > std::runtime_error and check what() to distinguish a failed cast from > > > another dolfin::error, which is pretty inconvenient. Is there a specific > > > reason why it is implemented this way? > > > > > > > Not really. > > > > It's not too clear to me what you'd like. Would you prefer that > > down_cast doesn't throw an error, but leave it up to the programmer to > > check that a cast was successful, or just that DOLFIN catch a > > std::bad_cast and print more information before throwing an error? > > I think the best would be if DOLFIN caught the error, then wrote an > informative message (since it knows exactly what went wrong) and then > threw bad_cast. >
Looks like there isn't much that can be done - std::bad_cast is only thrown when casting references, not pointers (as we do internally). From what I've read, our way of checking for a null pointer is correct. Garth > -- > Anders _______________________________________________ Mailing list: https://launchpad.net/~dolfin Post to : dolfin@lists.launchpad.net Unsubscribe : https://launchpad.net/~dolfin More help : https://help.launchpad.net/ListHelp