All pastes #1168100 Raw Edit

Stuff

public text v1 · immutable
#1168100 ·published 2008-08-12 14:57 UTC
rendered paste body
#include <iostream>

using namespace std;

template <int n,int w[n]>
struct test
 {
  test(){cout<<sizeof(w)/sizeof(w[0])<<' '<<sizeof(w)<<' '<<sizeof(w[0])<<endl;}
 };

int x[]={0,0,0,0,0,0,0};

int main()
{
  test<90,x> y;
  test< 7,x> z;
  cout<<sizeof(x)/sizeof(x[0])<<' '<<sizeof(x)<<' '<<sizeof(x[0])<<endl;
  
  /*
     The above code compiles without even warnings, and its output is:
     2 8 4
     2 8 4
     7 28 4

     so it seems like I have no chance to be absolutely sure about the array dimension in the template class.
  */

  return 0;
}