[Bug c++/94008] "use of deleted function" error when using "std::unique_ptr", std::move() and lambda
redi at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Tue Mar 3 09:51:00 GMT 2020
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94008
Jonathan Wakely <redi at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution|--- |INVALID
--- Comment #3 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Xuehan Xu from comment #0)
> test_lambda([test_uniq = std::move(test_uniq)] {
> test_lambda([test_uniq = std::move(test_uniq)] {});
The operator() of the closure object is a const member function, so test_uniq
is const and can't be moved. Attempting to move it will copy it, which fails
because unique_ptr is not copyable.
More information about the Gcc-bugs
mailing list