Boost logo

Boost :

From: Larry Evans (cppljevans_at_[hidden])
Date: 2006-01-24 15:49:48


On 01/20/2006 10:00 AM, David Abrahams wrote:
[snip]
> I hope you're reusing the visitor mechanism provided by the signals
> library for function detection:
> http://www.boost.org/doc/html/signals/s05.html#id2739308
>
 From looking at:

     template<typename V>
   void visit_each(V& v, const tracking_bridge& t, int)
   {
     v(t);
     v(t.sig);
   }

in $BOOST_ROOT/libs/signals/test/random_signal_system.cpp, I realized
the meaning of:

   a visit_each overload must be supplied for each object type.

in http://www.boost.org/doc/html/visit_each.html, i.e. the user must
explicitly call v(x) for each subobject, x, of T.

However, the phrase, 'for each subobject' in visit_each.html
is not really accurate since there is the subobject:

     minstd_rand& tracked_bridge::rand_gen;

in tracking_bridge.

Maybe "subobjects selected by user in the user's specialization of
visit_each" would be more accurate. Anyway, the essential difference
is that with visit_each, the user has to know which subobjects to
visit and has to explicitly code the visit. OTOH, with fields_visitor,
the user can select the object by "declaring" it visitable by wrapping
it in something derived from registrar_heirarchy. The visit_each
method is less intrusive (no need to modify the class to be visited),
but more work.

The following code:

   http://tinyurl.com/dx7rs

demonstrates how fields_visitor can be used to emulate a visit_each
method. The other example program, simple_*.cpp, shows how to do it just
using fields_visitor.

FYI, the preliminary fields_visitor users_guide in the vault has been
updated.

-best regards & thanks for the interest,
Larry


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk