← Back to team overview

dolfin team mailing list archive

Re: down_cast

 



Martin Sandve Alnæs wrote:
2008/4/13, Garth N. Wells <gnw20@xxxxxxxxx>:
In the down casting functions in GenericTensor, what's the difference
 between

   T* t = dynamic_cast<T*>(instance());

 and

   T* t = dynamic_cast<T*>(this);
 ?


// Assume this is configured to use a PETScVector:
GenericVector * v = new Vector();

// This won't work:
PETScVector * pv = dynamic_cast<PETScVector*>(v);

// This will work (and is what down_cast does):
PETScVector * pv = dynamic_cast<PETScVector*>(v->instance());

This was the only intended usage for instance().


OK. Thanks!

Garth


 Is there much overhead associated with a dynamic cast?

 Garth

I have no idea how much overhead there is, but I'm assuming it won't
be placed in inner loops anyway.

--
Martin



References