Boost logo

Boost Users :

From: Joel Falcou (joel.falcou_at_[hidden])
Date: 2008-06-05 07:38:04


Zeljko Vrba a écrit :
> 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
> }
> };

Can't a boost::tuple<v1,v2..,vn> with a custom, recursive constructor
function do the trick ?


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