Why can't we pass strings as template arguments? [on hold]
I know we can define templates using constants. For instance:
template<int N>
struct FixedArray {
double values[N];
int size() { return N; } // Could be static
};
int main(int, char**) {
FixedArray<10> arr;
arr.values[0] = 3.14;
cout << "first element=" << arr.values[0] << endl;
cout << "size=" << arr.size() << endl;
return 0;
}
This specific example lets us define an array with a constant size.
But why can't we pass strings as template arguments in C++?
The following slide is suppose to explain it but I'm not getting where the
problem is.
If someone can point it out to me and explain it I'd appreciate it. Thanks
No comments:
Post a Comment