I am starting to integrate smart pointers into my code. However, I am still getting stuck up on exactly how to use them. Here is the relevant code snippet:
bool DebugLayer::Init(
DebugOptions options,
const std::shared_ptr<Renderer> &renderer,
const std::shared_ptr<const InputController> &inputController,
const std::shared_ptr<const Timer> &timer,
const RECT& windowRect)
{
if(!inputController || !timer || !renderer || !inputController)
{
OutputDebugString("\nInvalid parameters passed to DebugLayer::Init()\n");
return false;
}
this->debugOptions = options;
this->renderer = std::make_shared<Renderer>(*renderer);
this->inputController = std::make_shared<const InputController>(*inputController);
this->timer = std::make_shared<const Timer>(*timer);
...
...
}
I am trying to pass const pointers to const objects into the function. For some reason, when I try and set my own class instance shared_ptr objects to what I pass into Init() I get the following errors from <memory>: