[Dune] Warnings about FieldVector::size

Martin Nolte nolte at mathematik.uni-freiburg.de
Tue Aug 16 19:37:46 CEST 2011


Hi Jö,

it seems I made a mistake when testing. At least for gcc it defining the static
constant in the header does compile and link even with multiple object files.
Don't know whether this is standard-conforming, though.

So, we can switch from an enum to a static const size_t. However we should be
aware that this might trigger additional signed / unsigned comparison warnings:

struct A
{
  //enum { size = 2 };
  static const int size = 2;
};

int main ()
{
  int i = 5;
  if( i != A::size )
    i = A::size;
  unsigned int j = 6;
  if( j != A::size )
    j = A::size;
}

All in all, I'm still not convinced. Notice that I do not argue against using
'static const' stuff in other places, we're just talking compatibility with
previous DUNE code, here.

Best,

Martin




More information about the Dune mailing list