template & lt; Typename T>notes at the bottom of the local head first release would happen
The class Queue
{
Private:
Struct Node
{
T data_;
STD: : unique_ptr & lt; Node> Next_;
Data Node (T) : data_ (STD: : move (data)) {}
};
STD: : unique_ptr & lt; Node> Head_ {nullptr};
Node * tail_ {nullptr};
Public:
STD: : from & lt; T> Try_pop ()
{
If (head_==nullptr)
Return STD: : from & lt; T> (a);
STD: : from & lt; T> Res (STD: : make_shared & lt; T> (STD: : move (head_ - & gt; Data_)));
//STD: : unique_ptr & lt; Node> Old_head=STD: : move (head_);
//head_=STD: : move (old_head_ - & gt; Next_);
Head_=STD: : move (head_ - & gt; Next_);
return res;
}
}
CodePudding user response:
No, you should check whether old_head_ is nullptr, if for nullptr old_head_ - & gt; Next_ complains