c++ - Can 'iterator' type just subclass 'const_iterator'? -


After having some doubts about my custom containers, in my container, iterator Const_iterator is a subclass of so that I can get a conversion from "non" to "free". But is this permission or do there any drawbacks or non-working scenarios for such setup?

Yes, that's fine. For example, VC10 has been prepared for the implementation of the grammar for the vector . _Vector_iterator and _Vector_const_iterator in & lt; Vector & gt; see

By the way, writing iterators is hard. This is the value of your time to learn and use the booster: Iterator library.


Comments