C++ Logo

std-discussion

Advanced search

Re: Member function release of std::unique_ptr

From: Robert A.H. Leahy <rleahy_at_[hidden]>
Date: Wed, 23 Jun 2021 22:11:53 +0000
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-23 17:11:58