fork download
  1. #include <functional>
  2. #include <iostream>
  3.  
  4. struct test
  5. {
  6. test() = default;
  7. test(const test &)
  8. {
  9. std::cout << "copied" << std::endl;
  10. }
  11. void func(int i)
  12. {
  13. std::cout << i << std::endl;
  14. }
  15. };
  16.  
  17. int main()
  18. {
  19. test t;
  20. std::function<void(int)> f1 = std::bind(&test::func, t, std::placeholders::_1);
  21. f1(1);
  22. }
  23.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
copied
copied
1