
Frank Mori Hess wrote:
However, my way also allows track() to be called an arbitrary number of times before connecting the slot. How would multiple tracked objects be handled with a track(p).connect()/.connect_to() syntax? If you allow track to take varying numbers of arguments, it requires the user to know how many tracked objects there will be at compile time. Being able to call track() multiple times only requires knowing the number of tracked objects at run time, which might be handy if the tracked objects are being collected in a container.
This is a good argument for the slot-based alternative. slot_type slot( f, ... ); for_each( tracked.begin(), tracked.end(), bind( &slot_type::track, _1 ) ); signal.connect( slot ); // or slot.connect_to( signal );
I suppose you could overload track to accept a container argument.
This would work well with the signal.connect( bind( f, ... ), tracked ); syntax, but we're losing the ability to drop the bind. :-)