fork download
  1. #include <iostream>
  2. #include <functional>
  3. #include <memory>
  4. #include <vector>
  5. using namespace std;
  6.  
  7. template<typename R>
  8. R f(bool x)
  9. {
  10. return x ? R() : R();
  11. }
  12.  
  13. template<typename R>
  14. struct X
  15. {
  16. X(const function<R()>& xfn) : fn(xfn) {}
  17. R get(bool f)
  18. {
  19. return f ? fn() : R();
  20. }
  21. function<R()> fn;
  22. };
  23.  
  24. int intf() { return 0; }
  25. void voidf() {}
  26.  
  27. void delme(int*) {
  28. cout<<"delme"<<endl;
  29. }
  30.  
  31. int main() {
  32. int k = 0;
  33. vector<shared_ptr<int>> v;
  34. v.emplace_back(new int(1));
  35. v.emplace_back(&k, &delme);
  36.  
  37. cout<<"============="<<endl;
  38.  
  39. shared_ptr<int> p = v.back();
  40. v.pop_back();
  41. return 0;
  42. }
Success #stdin #stdout 0s 15248KB
stdin
Standard input is empty
stdout
=============
delme