c++ - Remove item from std::list with only having access to the iterator -
std::list double linked list. doesn't mean should possible remove item list having access iterator?
maybe question wasn't clear enough.
#pragma once #include <list> typedef std::list<int> intlist ; typedef intlist::iterator intiterator; class inthiddenlist { private: intlist list; public: intiterator addint(int x) { list.push_front(x); return list.begin(); } }; int main() { inthiddenlist a; intiterator = a.addint(5); // how go deleting 5 list using "it"? }
yes, notionally it's possible. however, standard library not allow (it requires container , iterator erase).
however you're in luck: boost provides boost::instrusive
(http://www.boost.org/doc/libs/1_54_0/doc/html/intrusive/list.html) capability want.
Comments
Post a Comment