#include <memory> int main(){ int makeitcompile; [makeitcompile](std::unique_ptr<int> ICompile){}; //<--- This compiles. [](std::unique_ptr<int> IDoNotCompile){}; //<--- This does not. return 0; }
Tried it in VS2012.3 and VS2013.Preview.
A lambda that captures nothing but takes a unique_ptr by value will not compile. It trys to access the copy constructor of the unique_ptr which is obviously private. The extremely strange part is that if you have it capture a value, everything is happy, as shown above.
I can only assume this is a compiler bug since it obviously doesn't actually have to copy anything since the closures aren't being called.
EDIT:
I found a similar bug report on Microsoft Connect that suggests that they admit it is a compiler bug and that they won't fix it. ID#785222
TLDR, though I thought I was on a support forum so I should hope you read it:
Am I misunderstanding the C++ Standard or is this a compiler bug?