I'm new to smart pointers, and I'm in the process of hitting every stumbling block.
I have a struct texture_t
:
struct texture_t
{
hash32_t hash;
uint32_t width;
uint32_t height;
uint32_t handle;
};
When I try and make a shared_ptr
of this struct using this line:
auto texture_shared_ptr = std::make_shared<texture_t>(new texture_t());
I get this error:
error C2664: 'mandala::texture_t::texture_t(const mandala::texture_t &)' : cannot convert parameter 1 from 'mandala::texture_t *' to 'const mandala::texture_t &'
Where is this error coming from and how can I avoid it?
You are not supposed to pass a
new
ed pointer tostd::make_shared
. You just need to pass arguments from which atexture_t
can be constructed to it.