[Dune] Default constructor in MultiLinearGeometry

Christian Engwer christian.engwer at uni-muenster.de
Sun Oct 14 11:32:29 CEST 2012


Hi Martin,

> Apart from this, my feeling is that uninitialized objects are a very
> bad thing. Especially unexperienced programmers will have a hard
> time finding bugs caused by this. A default constructor would, of
> course, create an "uninitialized" geometry (in the sense that you
> may not use it at all).

while I agree, that RAII is a good idea, default constructors aren't a
bad thing in general. For example you won't be able to store objects
in a std::vector, unless they have a default constructor. This is due
to std::vectors' memory management, which tries to avoid
reallocations.

So I think a defaults constructor would be helpful. E.g. in dune-udg
we construct a set of entity-parts (geometries + something) between a
grid entity and a levelset. These entity-parts are stored (on demand,
for a single intersection) in an std::vector -- we are doing nearly
the same as return a copy on the fly, but we have to return a set and
thus need std::vector. A default constructor would allow us to switch
to MultiLinearGeometry, allowing faster computations.

In case the corner storage does not allow default-construction, we
still get a useful error message.

Cheers
Christian





More information about the Dune mailing list