shared_ptr型のベクトルのイテレータをキャストするにはどうすればよいですか?以下の例で考えてみましょう:shared_ptr型のベクトルのイテレータをキャスト
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();
}
可能重複します(http:// stackoverflowの.com/questions/505143/getting-a-normal-ptr-from-shared-ptr) – karlphillip