
On Feb 28, 2006, at 7:49 AM, Peter Dimov wrote:
Douglas Gregor wrote:
The Boost bug is an interaction between the storage optimizations that went in to Bind (to make the storage optimizations of Function actually useful) and the visit_each mechanism.
You're mixing these up. The bug in this thread is present in 1.33.1 which doesn't have the storage optimization. It only shows up on proper two-phase lookup compilers because the primary declaration of visit_each wasn't #included.
Ah, okay. In that case, I was fixing the other Signal/Bind bug that shows up in Boost CVS.
The patch seems good to me. There are several things that I don't like in the test, though; (a) it doesn't actually test anything, (b) it uses boost/test instead of lightweight_test.hpp, (c) it binds std::plus<> with one argument, which is invalid and can be rejected by a conforming bind.
You're right, of course. Thanks for the improved test case.
I tried to fix it, but an interesting question has come up. The primary visit_each is defined as:
template<typename Visitor, typename T> inline void visit_each(Visitor& visitor, const T& t);
By forcing a const qualification on the visited object, this interface prevents a visitor from mutating it (in addition to breaking when a function is being passed for t.) Is this deliberate or accidental?
I think it was deliberate when I originally implemented visit_each, because I wasn't imagining that it would be used for mutation. However, now I think it was the wrong decision... taking a non-const T& even has the side benefit of causing a failure if someone accidentally tries to stick a temporary into visit_each.
Anyway. Could you please look at the attached test case and confirm that it passes with your patch applied?
Yes, it passes on both GCC 4.0.1 and GCC 3.3. Doug