
AMDG On 07/26/2012 10:31 AM, Chapman, Alec wrote:
Hi Steven,
I have a somewhat-generic type erasure class that I would like to switch to yours. The main difficulty I can see is in the way capturing by reference is handled. The approach I take in my class is to pass a boost::reference_wrapper to the constructor:
<snip>
The problem is that there are significant differences between references and values. This is okay for Boost.Function, because Boost.Function doesn't expose ant mutating operations. However, in the more general case this behavior is too error prone. Just think about what would happen if we allowed using boost::ref for any_iterator. Some Algorithms assume that they can make copies of iterators and that these iterators are independent of each other. In Christ, Steven Watanabe