fork download
  1. #include <iostream>
  2. #include <functional>
  3. #include <vector>
  4.  
  5. int add(int a, int b) { return a + b; }
  6.  
  7. using bound_add_t = decltype(std::bind(add, std::placeholders::_1, int()));
  8.  
  9. int main() {
  10. std::vector<bound_add_t> vec;
  11. int y = 2;
  12. vec.emplace_back(add,std::placeholders::_1, y); // <- this causes the problem
  13. vec.emplace_back(add,std::placeholders::_1, 2);
  14. vec.emplace_back(add,std::placeholders::_1, 3);
  15.  
  16. for (auto &b : vec)
  17. std::cout << b(5) << std::endl;
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0s 3412KB
stdin
Standard input is empty
stdout
7
7
8