I am capturing a unique_ptr in a lambda expression this way:
auto str = make_unique(\"my string\"); auto lambda = [ capturedStr = std::move(str)
To make the advice more explicit: add mutable: http://coliru.stacked-crooked.com/a/a19897451b82cbbb
mutable
#include int main() { std::unique_ptr pi(new int(42)); auto ll = [ capturedInt = std::move(pi) ] () mutable { }; }