fork download
  1. #include <iostream>
  2. #include <functional>
  3.  
  4. using func_t1 = std::function<double( double )>;
  5. using func_t2 = std::function<double( double, double )>;
  6.  
  7. double f2( double x, double y )
  8. {
  9. std::cout << "f2(" << x << "," << y << ")" << std::endl;
  10. return x + y;
  11. }
  12.  
  13. int main()
  14. {
  15. using namespace std::placeholders;
  16. double fixed = 123;
  17. func_t1 fa = [fixed]( double x ) { return f2( x, fixed ); };
  18. func_t1 fb = std::bind( f2, _1, fixed );
  19. fa( 1 );
  20. fb( 2 );
  21. }
Success #stdin #stdout 0s 5512KB
stdin
Standard input is empty
stdout
f2(1,123)
f2(2,123)