"apply" member function over collection

Consider this: // new way, so far so good boost::range::for_each (mylist, std::tr1::bind(&C::foo, _1)); // original: // for(Collection::iterator fi = mylist.begin(); fi != mylist.end(); ++fi) { // Collection::reference item = *fi; // item->foo(); // } I've got a zillion of these one-shot "for" loops, and I was able to change this sample to use a range::for_each. But, it's still too ackward and will be unfamiliar to other users, so it has to be "sleek or bust"! The item type is actually a smart pointer. Is there a more succinct way of writing it, without needing the extra placeholder to be mentioned? The for_each works find as an "apply" except that the member function needs to be adapted; it won't do that by itself. I found that boost::range::for_each (Filters, std::tr1::mem_fn(&VseeMediaFilter::Uninitialize)); compiles too, even though I'll be passing a smart pointer to the resulting adapted function. But, as mentioned on another thread, mem_fn is deprecated? How might I write this more tersely, or provide an 'apply' utility of my own that does what I want? Thanks, —John
participants (1)
-
John M. Dlugosz