Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <functional> // for function
- #include <memory> // for unique_ptr
- #include <utility> // for move
- std::function<int()> makeLambda(std::unique_ptr<int> ptr)
- {
- return [p = move(ptr)] { return *p; };
- }
- int main()
- {
- // Works
- auto function1 = [p = std::make_unique<int>(10)] { return *p; };
- // Does not work
- auto function2 = makeLambda(std::make_unique<int>(10));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement