How can I cast an iterator of a vector of shared_ptr type? Consider following example:
typedef boost::shared_ptr < MyClass > type_myClass;
vector< type_myClass > vect;
vector< type_myClass >::iterator itr = vect.begin();
while(itr != vect.end())
{
//Following statement works, but I wish to rather cast this
//to MyClass and then call a function?
(*itr)->doSomething();
}
You do not want to cast, but rather extract a reference to the object: