On Wed, 4 Feb 2009, Derek Gaston wrote:

> So I just tried to use libmesh_cast_ptr for the first time.... and I'm
> not  really sure about the interface.  Here's what I'm doing
>
> PetscMatrix<T> * pmatrix = libmesh_cast_ptr<PetscMatrix<T>*,
> SparseMatrix<T> >(this->_matrix);

Try:

PetscMatrix<T> *pmatrix = libmesh_cast_ptr<PetscMatrix<T>*>(this->_matrix);

Told gets automatically inferred from the argument type; you shouldn't
have to explicitly specify it at all.

And this way it looks like a regular C++ something_cast<Something*>().

> What I don't like is how you have to pass Tnew as a pointer type (ie
> with a *) but Told you pass _without_ a *.  I don't really care either
> way... but it feels like both arguments should be the same.

The status of Tnew as a pointer is to make the syntax look like a C++
cast.

The status of Told as a non-pointer was originally intended to allow
both "libmesh_cast_ptr" and "libmesh_cast_ref" to have the same name,
"libmesh_cast", but I never quite got the overloading working
correctly - IIRC the compiler couldn't decide that a pointer-to-Told
shouldn't really be interpreted as a reference-to-Told (where Told is
now a pointer-to-T) instead.

Should we change Told to be a pointer too?  That will still be API
compatible, but it might make error messages more confusing when
someone accidentally calls libmesh_cast_ptr(some_non_pointer).
---
Roy

------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com
_______________________________________________
Libmesh-devel mailing list
Libmesh-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libmesh-devel

Reply via email to