[Dune] dune-common r5260 - trunk/common

Markus Blatt Markus.Blatt at ipvs.uni-stuttgart.de
Mon Oct 20 00:21:09 CEST 2008


Hi

On Tue, Sep 16, 2008 at 11:34:46AM +0200, Robert Kloefkorn wrote:
> 
> the thing about FieldVector<K,0> is that it should be really an empty 
> class without any memory consumption. The warning was only a side effect.
> 

Zero memory consumption? I doubt that one. Even empty classes occupy
space. Every object consumes at least one byte. You can test this
rather easily:

#include<dune/common/fvector.hh>
#include<iostream>

int main(){
        std::cout<<sizeof(Dune::FieldVector<double,0>)<<" "
        <<sizeof(Dune::FieldVector<double,0>[4])<<std::endl;
}


The only way to benefit in terms of memory consumption is to
derive from FieldVector because of empty base class optimization of
the compiler. Are you really doing that?

Cheers,

Markus




More information about the Dune mailing list