fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. struct Foo {
  5. Foo(int num) : num_(num) {std::cout << "Hello World" << std::endl;}
  6. Foo(const Foo& f) : num_(f.num_) {std::cout << "Hello World copy" << std::endl;}
  7. ~Foo() {std::cout << "Goodby World" << std::endl;}
  8. void print_add(int i) const { std::cout << num_+i << '\n'; }
  9. int num_;
  10. };
  11.  
  12. int main()
  13. {
  14. using std::placeholders::_1;
  15. std::function<void(int)> f_add_display59 = std::bind( &Foo::print_add, Foo(75), _1 );
  16.  
  17. }
  18.  
Success #stdin #stdout 0s 4312KB
stdin
Standard input is empty
stdout
Hello World
Hello World copy
Hello World copy
Goodby World
Goodby World
Goodby World