I have Class which returns std::shared_ptr aka Product_SPTR:
Product_SPTR Mill::Production(sf::Time time)
{
if(m_isProducing)
{
if(elapsedTime.getElapsedTime()>m_manufacturingTime)
{
elapsedTime.restart();
Flour_SPTR a(new Flour(5,1,ProductType::CONSTRUCTION),deleter<Flour>);
return a ;
}
}
}
then i have typedef std::vector<Product_SPTR> VectorProduct_SPTR
and when I'm trying to add new Product_SPTR to vector i have segmentation fault
Here:
products.push_back(a->Production(gameTime.getElapsedTime()));
But when I do something like this:
products.push_back(new Flour(5,1,ProductType::CONSTRUCTION),deleter<Flour>);
problem does not occur....
I have just started to use smart pointers so maybe i don't know how to use it ..
deleter
? What doesMill::Production
return whenm_isProducing
is false? Do you post complete code?