c++ - Erase element from std::list using a pointer? -
class sororitybeerexpo{ public: std::list<layscrankdpepchip> m_chiplist; void destroychip(layscrankdpepchip * target) { // m_chiplist needs erase pointed @ target // erase() requires iterator not got work // remove() needs value not right either } } my question, how 1 delete element in list, pointer points element? without using iterators in place of pointers.
you can [linear] search element in list, comparing address of each element pointer (std::find_if fit bill). of course, still using iterator in end, because that's list::erase needs.
Comments
Post a Comment