ExOttoyuhr
ExOttoyuhr

Reputation: 677

How to reset a shared_ptr?

I'm trying to do this (using a custom class, and STL shared_ptr from #include <memory>):

shared_ptr<Label> BufLbl;

BufLbl = allocate_shared<Label>(Label());
BufLbl->YCoord = 3;
BufLbl->XCoord = 2; 
BufLbl->Width = 5;
BufLbl->Data = "Day 1";
Screen.Controls.push_back(BufLbl);

BufLbl = allocate_shared<Label>(Label());
BufLbl->YCoord = 4;
BufLbl->XCoord = 6; 
BufLbl->Width = 1;
BufLbl->Data = "2";
Screen.Controls.push_back(BufLbl);

<repeat>

I'm getting this error:

error C2903: 'rebind' : symbol is neither a class template nor a function template

What am I doing wrong?

Upvotes: 1

Views: 231

Answers (1)

Kerrek SB
Kerrek SB

Reputation: 477640

You're abusing allocate_shared, which isn't what you think.

What you need is make_shared, like this:

BufLbl = std::make_shared<Label>();

Upvotes: 2

Related Questions