fork download
  1. #include <iostream>
  2.  
  3.  
  4. template <int size>
  5. void f( int (&a)[size] )
  6. {
  7. std::cout << sizeof(a)/sizeof(*a) << std::endl;
  8. }
  9.  
  10. int main() {
  11.  
  12. int a[] = {1,2};
  13. int b[] = {1,2,3};
  14. int c[] = {1,2,3,4,5};
  15.  
  16. f(a);
  17. f(b);
  18. f(c);
  19.  
  20. return 0;
  21. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
2
3
5