Open Bug 948538 Opened 12 years ago Updated 3 years ago

Add STL iterator support to XPCOM datatypes

Categories

(Core :: XPCOM, defect)

x86_64
Linux
defect

Tracking

()

People

(Reporter: jcranmer, Unassigned)

Details

For better or worse, the STL and C++ libraries are built around iterator concepts. Adding iterators to our ADTs would allow us to use <algorithm> helpers if we so chose (there might be codesize concerns with std::sort, but the std::lower_bound/std::push_heap, etc.-equivalent functions in nsTArray all appear to be templated anyways, so we'd probably lose no codesize there). Also, iterators would allow us to use range-based for when our min requirements are >MSVC 2013 and >gcc 4.6. One concern bsmedberg brought up over IRC is whether or not iterators should be mutation-safe. C++11's rules for iterator safety on std::vector basically boil down to "if the pointer in the iterator would no longer point to the correct thing, it's invalid." We can make iteration be mutation-safe by an extra level of indirection, but given that STL generally isn't mutation-safe, it may be more advantageous just to have debug-only assertions if you try to use an invalidated iterator. Thoughts?
I think debug only assertions are fine. We should not try to provide a strong guarantee than the STL provides for the sake of compatibility with its API.
Debug only assertions sound fine to me.
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.