fork download
  1. #include <iostream>
  2.  
  3. int main()
  4. {
  5. // If I change T x to T& x, it won't compile. Why not?
  6.  
  7. auto l = []<typename T>(T x, int y){ return x + y; };
  8.  
  9. std::cout << l(3,5) << std::endl;
  10. std::cout << l(3.14,5.7) << std::endl;
  11.  
  12. return 0;
  13. }
Success #stdin #stdout 0.01s 5292KB
stdin
Standard input is empty
stdout
8
8.14