[cfe-commits] Mark virtual members used in a deterministic order
Rafael EspĂndola
rafael.espindola at gmail.com
Sun Aug 26 20:15:58 PDT 2012
On 26 August 2012 22:17, Chandler Carruth <chandlerc at google.com> wrote:
> Rather than a special purpose data structure here, could you instead build a
> MapVector analogous to SetVector which works essentially the same way and
> provides nice stable iteration order?
I started that way, but I found some issues trying to make this a
generic structure:
* The values can be mutated, so they must live only on the vector or in the map.
* The "map to vector index" pattern does not support deletions without
having a thumb stone for values.
* Since the key and the value are in separate areas in memory, I could
not find a way to have operator-> return a pointer to a std::pair<Key,
Value>.
* A tried returning a "fake std::pair class" which itself had a
operator-> and first and second methods, but all that this got was
that the iterators could be use as "I->first()" instead of "I.first()"
This is when I gave up, deleted the "fake std::pair" and rename
first() and second() to the explicit getKey and getValue.
Have you seen some structure like this before? Can you think of a way
to make the iterator behave like a regular stl iterator?
Cheers,
Rafael
More information about the cfe-commits
mailing list