Please help me! I want to call a virtual function of objects in std::list while using std::for_each:
 
struct DiscardableItem {
    void Discard() {
        std::cout<<"Discard item!"<<std::endl;
    }
};
std::list<DiscardableItem*> items;
items.push_back(new DiscardableItem);
items.push_back(new DiscardableItem);
std::for_each( items.rbegin(), items.rend(), _1->*&DiscardableItem::Discard );
 
But DiscardableItem::Discard does not be called. How can I make it work? thanks! I think lambda can solve this problem easily.