fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <int N> int getSize(int (&arr)[N]) {
  5. return sizeof(arr);
  6. }
  7.  
  8. int main() {
  9. int arr[] = { 1, 2, 3, 4 };
  10. cout << getSize(arr) << endl;
  11. cout << sizeof(arr) << endl;
  12. return 0;
  13. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
16
16