]> https://gitweb.dealii.org/ - dealii.git/commit
Do not instantiate invalid classes. 3639/head
authorWolfgang Bangerth <bangerth@colostate.edu>
Sat, 26 Nov 2016 05:17:56 +0000 (22:17 -0700)
committerWolfgang Bangerth <bangerth@colostate.edu>
Sat, 26 Nov 2016 05:17:56 +0000 (22:17 -0700)
commit9386b1e30c902adefda56f85e9bd9af86687d8e8
treec69a392d848bfa0f94a8c88bf25e947e29b13f35
parentc01401239ac32e79ddf43980cf3be163ebeb43f5
Do not instantiate invalid classes.

We have numerous places where we do something of the sort

  template <int dim, int spacedim>
  void foo (const Triangulation<dim,spacedim> &triangulation) {
    if (dim == 3)
      {
        typename Triangulation<3,spacedim>::cell_iterator cell = triangulation.begin();
        ...

Since we only get into this piece of code if dim==3, there is nothing wrong with
this: if dim==3, then spacedim>=3. On the other hand, the compiler will still
instantiate Triangulation<3,spacedim> even if dim==spacedim==1.

This patch works around this by replacing the type by
  Triangulation<3,max(3,spacedim)>
which for all of the cases in question leads to the exact same type, but
avoids instantiating invalid types.
source/grid/tria_accessor.cc

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.