I vaguely remember reading somewhere that this was bad practice, but had to do it just to get around the compiler error:
Code:
typedef stl_container<type> A;
typedef different_container<type*> B;
A a;
B b;
for(A::iterator it = a.begin(); it != a.end(); it++)
{
b.insert(&(*it)); //dereference, then apply addressof operator again
}
Let me emphasize that there is no way for me at the moment to get around this. I need to work on the original object later on, and not a copy. That's why I need to pass around a reference.
What's the recommended way of doing this? And why is my kludge(?)workaround(?) discouraged?