fork download
  1. #include <iostream>
  2.  
  3. template < typename T, std::size_t N > void foo( T(&array)[N] )
  4. {
  5. std::cout << "size: " << sizeof(array)
  6. << " num elements: " << N << '\n' ;
  7. }
  8.  
  9. int main()
  10. {
  11. int a[23] ; foo(a) ;
  12. const double b[57] = {0} ; foo(b) ;
  13. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
size: 92    num elements: 23
size: 456    num elements: 57