【发布时间】:2018-05-26 07:02:48
【问题描述】:
AFAIK 非可变 lambdas 将变量捕获为 const。这让我很奇怪,为什么它们还能被移动?
auto p = std::make_unique<int>(0);
auto f = [p = std::move(p)](){ p->reset(); }; // Error, p is const
auto f2 = std::move(f); // OK, the pointer stored inside lambda is moved
【问题讨论】:
标签: c++ lambda c++14 move-semantics