
Larry Evans <cppljevans@cox-internet.com> writes:
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.
Correct.
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.
Technically speaking, that code is wrong and the phrase is accurate.
Maybe "subobjects selected by user in the user's specialization of visit_each" would be more accurate.
I don't think so. That's tautological.
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.
I don't see how wrapping the object is going to tell your registrar where the subobjects are.
The visit_each method is less intrusive (no need to modify the class to be visited), but more work.
The following code:
demonstrates how fields_visitor can be used to emulate a visit_each method.
A lot of code, almost no comments. It's not very clear what it's supposed to be doing or illustrating.
The other example program, simple_*.cpp, shows how to do it just using fields_visitor.
where is that? You must mean simple_record_field_traversal_test.cpp Also not very clear to me. The use of "arg<1>" instead of "_1" is not very idiomatic, which --though it's minor-- doesn't help, IMO. -- Dave Abrahams Boost Consulting www.boost-consulting.com