fork download
  1. #include <iostream>
  2.  
  3. template<typename T, std::size_t N>
  4. std::size_t sizeof_array(T (&t)[N])
  5. {
  6. return N;
  7. }
  8.  
  9. int main()
  10. {
  11. int arr[] = {0, 1, 2, 3, 4};
  12. std::cout << sizeof_array(arr) << std::endl;
  13. }
  14.  
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
5