Boost logo

Boost :

From: David Abrahams (abrahams_at_[hidden])
Date: 2000-07-03 23:20:48


----- Original Message -----
From: <jsiek_at_[hidden]>

> So there's this workaround I'm tempted to use:
>
> typedef list<foo>::iterator list_iter;
> typedef list<list_iter> A;
> typedef list<list_iter> B;
>
> And then cast the list_iter to the real iterator type. I think this
> should be safe... anyone disagree?

Sure I disagree! ;)
Well, it will work on most machines/compilers/libraries, but "should be
safe" is pushing it a bit, I think.

> Is this a common enough problem that there should be a general
> solution? Somethink like a void_iterator that can do everything a
> normal iterator can do, except be dereferenced (and which also can
> be converted back to a non-void iterator).

Hmm, I'm not sure exactly what you're doing, but I've had to implement
associative containers indexable by 2 different keys; I ended up storing an
iterator to one map in the other, but a pointer to the elements in the
first. Don't know if this helps for your case, though.

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk