Strange initialization code for Particle layouts

Richard Guenther rguenth at tat.physik.uni-tuebingen.de
Sun Jul 11 15:49:59 UTC 2004


Hi!

There is some strange code in the particle layout initializations:

template <class M, class FL>
class SpatialLayout
   : public PatchSwapLayout< SpatialLayout<M,FL> >
{
public:
[...]
   // Default constructor.  Initialize with assignment operator.

   SpatialLayout()
     : Base_t(*this)
     {}


what is this idiom Base(*this) supposed to do!?  PatchSwapLayout doesn't 
define an assignment operator, so the comment doesn't make any sense. 
It looks like this initialization provokes undefined behavior and such 
can be dropped in favor of default-construction (which the 
PatchSwapLayout doesn't define)?  I'm confused, so maybe someone could 
shed a light on me here.  I guess the layout_m member of PatchSwapLayout 
could be implemented as static_cast<Layout_t>(*this) rather than playing 
this "trick"?

Thanks,
Richard.



More information about the pooma-dev mailing list