I have this code which causes a strange error:
void NBodySim::DrawCSOutput(std::shared_ptr<NBody::Renderer> graphics)
{
try
{
graphics->SBatch->Begin();
RECT destRect;
destRect.left = 0;
destRect.right = 256;
destRect.bottom = 256;
destRect.top = 0;
graphics->SBatch->Draw(this->uavSrv, destRect);
graphics->SBatch->End();
}
catch(std::exception e)
{
const char *wat = e.what();
int i = 0;
}
}
//DrawCSOutput() is called like this:
this->sim.DrawCSOutput(std::shared_ptr<NBody::Renderer>(this->graphics));
//this is the graphics member variable:
Renderer graphics;
I have managed to fix the code by changing the function to take a weak pointer instead but I am wondering, how can I successfully pass std::shared_ptr<T> as an argument to a function?