Original Post
Hello, I'm trying to update my resourceManager to use boost::shared_ptrs, but have hit a hole in my knowledge! When I normally allocate a shared_ptr elsewhere, I do so like this: boost::shared_ptr obj(new CMyObject); using a default constructor. works fine. In my resource manager, which is a template, I get confused. Here's what I am trying: The type is a cTexture whose constructor looks like this: cTexture( std::string name, std::string path = "data\\shaders\\" ); The compiler complains on the line: boost::shared_ptr resource(new Type( name, path )); Saying: I don't understand why the template type is shared_ptr, not cTexture. Why can't it see the cTexture constructor? Thanks in advance. Si
boost::shared_ptr<Type> Add( std::string name, std::string path = "" )
{
// If the element already exists, then return a pointer to it.
boost::shared_ptr<Type> element = GetElement( name );
if( element != NULL )
{
g_log->SIM( "Resource already in use: %s\n", const_cast<char*>(name.c_str()) );
return element;
}
// Create the resource
boost::shared_ptr<Type> resource(new Type( name, path ));
g_log->SIM( "New resource required: %s\n", const_cast<char*>(name.c_str()) );
// Add the new resource to the manager and return a pointer to it.
return *(m_list->Add( &resource ));
}
error C2661: 'boost::shared_ptr<T>::shared_ptr' : no overloaded function takes 2 arguments
with
[
T=cTexture
]
while compiling class template member function 'boost::shared_ptr<T> ResourceManager<Type>::Add(std::string,std::string)'
with
[
T=boost::shared_ptr<cTexture>,
Type=boost::shared_ptr<cTexture>
]