Sayid
Sayid

Reputation: 1113

Getting the index of an element in a deque given a pointer to that element?

Is there any way to get the index of an element from a pointer to the element? To be specific, what I need is the index (or iterator) to the element preceding or following the one I point. I know that when using vectors you can easily do the arithmetics but in a deque it is not so easy.

I have to use deque. Vectors are not an option.

Upvotes: 1

Views: 1687

Answers (1)

Gareth McCaughan
Gareth McCaughan

Reputation: 19981

I believe the answer is no. But why not use iterators rather than pointers throughout?

Upvotes: 1

Related Questions