Boost logo

Boost Users :

From: Zeljko Vrba (zvrba_at_[hidden])
Date: 2008-06-05 06:58:18


I have a following situation:

class X {
  type1 v1;
  type2 v2;
  ...
  typen vn;
  other_var ...
public:
  X() : v1(this), v2(this), .., vn(this), other_var(1, 2, 3)
  { }
};

I'm looking for suggestions on how to automatically initialize
variables v1..vn with "this" being passed as the only argument
to their constructor. In the ideal case, the programmer should
not need to specify any constructor calls for v1..vn, so that
the end result looks something like:

class X {
  type1 v1; ... typen vn;
  other_var;
public:
  X() : other_var(1, 2, 3)
  {
    // some "magic" arranges that v1(this) .. vn(this) is called
  }
};

Thanks!


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net