Original Post
I am just starting to learn how to use boost::shared_ptr and had a few questions about how to return a proper value from an std::list when the value of that list is a boost::shared_ptr. 1) I am little bit confused as to what the return object should be. I orginally been using this functio to return Mesh objects out of a std::list of Mesh object. Not shared_ptr. And it work fine by returning a Mesh object. 2) Am I suppose to wrap my iterator in (*) to access the functions of the object it is pointing to? 3) I am not sure what the return value would be. Regards Chad
// "Mesh" is a class
typedef boost::shared_ptr<Mesh> MeshPtr;
std::list< MeshPtr > m_meshList;
//1) I think I want to return that object?
Mesh Graphics::GetMesh( const std::string &meshName )
{
std::list< MeshPtr >::iterator listIterator;
// Find the font.
for( listIterator = m_meshList.begin(); listIterator != m_meshList.end(); listIterator++ )
{ // 2) is wrapping listIterator in (* ) correct?
if( (*listIterator)->GetMeshName() == meshName )
{
// 3) This obviously does not work
return *listIterator;
}
}
return Mesh();
}