#include <iostream>
#include <memory>
#include <functional>
using namespace std;

int main() {

  unique_ptr<int> uptr = make_unique<int>(5566);
  std::function<void()> func;
  // 1. Why compile error... 
  // func = std::bind([](unique_ptr<int> &&uptr2) {cout << *uptr2 << endl; }, std::move(uptr)); 
  // func();
  // 2. Why can I only write auto for deduction?
  auto func2 = std::bind([](const unique_ptr<int>& uptr2/*no const is OK but why?*/)
                           {	cout << *uptr2 << endl; },
                         std::move(uptr)); 
  // only can use "const &" to invoke func2?
  // && or by value will compile error, but "&" can run successfully without reason....                         
  func2();
  auto func3 = std::bind([](unique_ptr<int> uptr2) {cout << *uptr2 << endl; }, std::move(uptr));
  //func3(); // 3. How to invoke func3?... compile error

  return 0;
}