[signals] maximum combiner example calls slot twice
In http://www.boost.org/doc/libs/1_38_0/doc/html/signals/tutorial.html, once I read: "The input iterators passed to the combiner transform dereference operations into slot calls" I realized that the maximum<T> combiner introduced earlier is implemented using: if (max_value < *first) max_value = *first; Which ends up calling the slot twice. In this case it's harmless since the slot has no side effect, but it may not be a good example to follow, or maybe it should be pointed out a little later when the combiner deref statement quoted above is made. Just my $0.02. Thanks, --DD
On Friday 24 April 2009, Dominique Devienne wrote:
In http://www.boost.org/doc/libs/1_38_0/doc/html/signals/tutorial.html, once I read:
"The input iterators passed to the combiner transform dereference operations into slot calls"
I realized that the maximum<T> combiner introduced earlier is implemented using:
if (max_value < *first) max_value = *first;
Which ends up calling the slot twice.
Dereferencing a slot call iterator multiple times only runs the slot once. After that, it returns a cached copy of the return value.
On Fri, Apr 24, 2009 at 12:41 PM, Frank Mori Hess
On Friday 24 April 2009, Dominique Devienne wrote:
Which ends up calling the slot twice.
Dereferencing a slot call iterator multiple times only runs the slot once. After that, it returns a cached copy of the return value.
Thanks for the precision, and correcting my invalid assumption. I missed the caching property of slot call iterators in the doc. Thanks, --DD
participants (2)
-
Dominique Devienne
-
Frank Mori Hess