G
gipsy boy
I make an object of type A on the heap.
A oba;
I put it in a set S<A> (with a trivial comparator)
Set<A,Acomp> s;
s.insert(A);
Then I need to retrieve the pointer to the entry in that set (I want to
link some objects, without using a 'new' pointer - cause I want oba to
disappear when I exit this scope, I don't want to manually delete anything)
With a list you can easily do this with :
A* = & (*L.find(oba));
Then I can do A->changeMe(); etc..
But with a set, I can't do this, because the iterator is one of const
elements! It says I can't cast const A* to A*
I only want to use a set so the elements are sorted automatically. What
can I do about this?
A oba;
I put it in a set S<A> (with a trivial comparator)
Set<A,Acomp> s;
s.insert(A);
Then I need to retrieve the pointer to the entry in that set (I want to
link some objects, without using a 'new' pointer - cause I want oba to
disappear when I exit this scope, I don't want to manually delete anything)
With a list you can easily do this with :
A* = & (*L.find(oba));
Then I can do A->changeMe(); etc..
But with a set, I can't do this, because the iterator is one of const
elements! It says I can't cast const A* to A*
I only want to use a set so the elements are sorted automatically. What
can I do about this?