After another question about iterators I’m having some doubts about custom containers. In my container, iterator is a subclass of const_iterator, so that I get conversion from non-const to const “for free”. But is this allowed or are there any drawbacks or non-working scenarios for such a setup?
After another question about iterators I’m having some doubts about custom containers. In my
Share
Yes, this is fine. This is how VC10’s implementation of the iterators for
vectorare structured, for example. See_Vector_iteratorand_Vector_const_iteratorin<vector>.By the way, writing iterators is hard. It’s worth your time to learn and use the boost::iterator library.