[Dune] Unnecessary reinterpret_cast in AlbertaGrid
Christian Engwer
christi at uni-hd.de
Wed Dec 2 22:36:48 CET 2009
Hi Martin,
On Wed, Dec 02, 2009 at 08:15:30PM +0100, Martin Nolte wrote:
> We are talking about a deprecated method (operator []). The way I see it, there
> are 3 possibilities:
> (a) reinterpret_cast double[ dim ] to FieldVector< double, dim >
> (b) DUNE_THROW( NotImplemented )
> (c) return a reference to a static variable held within the method
>
> I decided for (a) because it does what is most expected: It simply works (unless
> you use gcc-4.4). Is there another solution or is (b) or (c) preferable to (a)?
> What do you think?
I thought that "elementInfo_.coordinate( i )" already return a
FieldVector, but perhaps I looks at the wrong spot.
If the return value is "double *" you can use a placement new.
return * new ( elementInfo_.coordinate( i ) ) GlobalVector;
If it returns "const double *" you have more problems, because "const *"
can't be used as a memory address for a placement new (or you have to
use a const_cast).
Christian
>
> Martin
>
> Christian Engwer wrote:
> > I believe the following cast is not necessary.
> >
> > ./dune/grid/albertagrid/geometry.hh:495: return reinterpret_cast<
> > const GlobalVector & >( elementInfo_.coordinate( i ) );
> >
> > Martin... could you comment on this?
> >
> > Christian
> >
> > _______________________________________________
> > Dune mailing list
> > Dune at dune-project.org
> > http://lists.dune-project.org/mailman/listinfo/dune
>
More information about the Dune
mailing list