C++ Logo

std-discussion

Advanced search

Re: Member function release of std::unique_ptr

From: Vladimir Grigoriev <vlad.moscow_at_[hidden]>
Date: Thu, 24 Jun 2021 13:43:22 +0300
And why are you using release instead of reset in your example?
 
With best regards,
(Vlad from Moscow)
You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
 
  
>Четверг, 24 июня 2021, 1:11 +03:00 от Robert A.H. Leahy <rleahy_at_[hidden]>:
>
>That would produce a false positive on this snippet:
>
>std::vector<int*> v;
>// Assume there is machinery here that deletes
>// all pointers in v on scope exit
>auto ptr = std::make_unique<int>(5);
>v.push_back(ptr.get());
>ptr.release();
>
>Thanks,
>
>--Robert
>
>
>----------------------------------------------------------------------
>From: Std-Discussion < std-discussion-bounces_at_[hidden] > on behalf of Vladimir Grigoriev via Std-Discussion < std-discussion_at_[hidden] >
>Sent: Wednesday, June 23, 2021 18:08
>To: std-discussion < std-discussion_at_[hidden] >
>Cc: Vladimir Grigoriev < vlad.moscow_at_[hidden] >
>Subject: [std-discussion] Member function release of std::unique_ptr
>
>Why does not the member function release of the class template std::unique_ptr have the attribute nodiscard?
>
>With best regards,
>(Vlad from Moscow)
>
>You can meet me at http://cpp.forum24.ru/ or www.stackoverflow.com or http://ru.stackoverflow.com
 

Received on 2021-06-24 05:43:30