Capturing perfectly-forwarded variable in lambda
问题 template<typename T> void doSomething(T&& mStuff) { auto lambda([&mStuff]{ doStuff(std::forward<T>(mStuff)); }); lambda(); } Is it correct to capture the perfectly-forwarded mStuff variable with the &mStuff syntax? Or is there a specific capture syntax for perfectly-forwarded variables? EDIT: What if the perfectly-forwarded variable is a parameter pack? 回答1: Is it correct to capture the perfectly-forwarded mStuff variable with the &mStuff syntax? Yes, assuming that you don't use this lambda