
Excellent, spot on, thanks gurus :-) /Peter Åberg Steven Watanabe wrote:
If the caller of push knows the type of the function object, then you can template the push function.
template<class F> void push(const F& f) { if(std::find_if(queue.begin(), queue.end(), f == _1) != queue.end()) { queue.push_back(item); } }
This is going to be pretty inefficient because of the linear search, but the same idea applies if you want to store the function objects in a data structure that supports faster lookup.
In Christ, Steven Watanabe
Nat Goodspeed Wrote:
You're right that we can't compare two boost::function objects, but it *is* permitted to compare a boost::function with an rvalue that could initialize it. If you make your push() method a template accepting an argument of arbitrary type, presumably you could compare each existing item with that new value before storing it into the deque.