Is it safe to dereference a temporary std::shared_ptr?
Example:
std::shared_ptr<std::string> create_shared_string()
{
return std::shared_ptr<std::string>(new std::string("hello"));
}
std::cout << *create_shared_str() << std::endl;
My fear is that the shared_ptr is destroyed and the reference counter goes to zero as soon as the dereference is complete and thus the returned raw pointer is no longer safe.