fork(5) download
  1. #include <functional>
  2. #include <iostream>
  3. #include <memory>
  4.  
  5. struct Toto
  6. {
  7. void foo( int param )
  8. {
  9. std::cout << "foo: " << param << std::endl;
  10. }
  11. };
  12.  
  13. int main() {
  14. std::shared_ptr<Toto> ptr = std::make_shared<Toto>();
  15. std::function< void(int) > func( std::bind( &Toto::foo,
  16. std::bind( [ptr] () { return ptr.get(); } ),
  17. std::placeholders::_1
  18. ) );
  19.  
  20. func( 1 );
  21. }
  22.  
Success #stdin #stdout 0s 3432KB
stdin
Standard input is empty
stdout
foo: 1