Re: What is the best way to iterate over a map? (or any paired container)
David Abrahams wrote:
"Diego Martins" <jose.diego@gmail.com> writes:
I appreciate your quick answers, but all of them were boost
related and I can't use boost in my software due to project
policies. Anyway, I want to learn how to build an iterator
wrapper.
If you can't use Boost, then study the standard iterator
requirements very, very carefully. It's very easy to write
"iterators" that seem to work in your tests but don't meet the
standard's definition of iterators, so they fail in subtle
ways when used where a standard iterator is expected.
Been there, done that. I'm actually pretty good at writing
non-conformant iterators... that work most of the time (and pass
all of my own tests).
What I've found useful in such cases is to compiler with a
concept checking version of the library. A recent version of
g++, with -D_GLIBCXX_CONCEPT_CHECKS -D_GLIBCXX_DEBUG
-D_GLIBCXX_DEBUG_PEDANTIC can find a lot of errors.
--
James Kanze GABI Software
Conseils en informatique orient?e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S?mard, 78210 St.-Cyr-l'?cole, France, +33 (0)1 30 23 00 34
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]