D
David Richardson
Does anyone know if this code is legal?
template<typename T>
struct holder{
holder(T &t):t_(t){};
T t_;
};
int main(){
int *a = new int[10];
int *front_of_a = &a[0];
holder<int*> h1(a);
holder<int*> h2(front_of_a);
//below does not compile with gcc 3.3.1, icc 6.0, icc 7.0
holder<int*> h3(&a[0]);
}//main
It seems to me like the line where h2 is instantiated should have the
same type as the line with h3 is. But gcc and icc disagree. Does
anyone know what is happening here? The gcc error indicates that T =
int* for h3.
Thanks,
Dave
template<typename T>
struct holder{
holder(T &t):t_(t){};
T t_;
};
int main(){
int *a = new int[10];
int *front_of_a = &a[0];
holder<int*> h1(a);
holder<int*> h2(front_of_a);
//below does not compile with gcc 3.3.1, icc 6.0, icc 7.0
holder<int*> h3(&a[0]);
}//main
It seems to me like the line where h2 is instantiated should have the
same type as the line with h3 is. But gcc and icc disagree. Does
anyone know what is happening here? The gcc error indicates that T =
int* for h3.
Thanks,
Dave