Is it safe to use template <size_t N> to find size of a dynamic array

Hi,

Is it safe to use the below code to get size of a dynamic array?
If not, what kind of problems can I get with it?

In my case, I have to pass the array named stringVals to 2 other functions to make the code refractored, so I will have to find the size of array dynamically 3 times.

[code]
template <size_t N>
void compare(string name, string stringVals[][N]){

do some processing using stringVals and name
}
[/code

Regards
I belive this is what you meant:
1
2
3
4
5
template <size_t N>
void compare(string name, string stringVals[][N]){

//do some processing using stringVals and name
}
Yes!
You can't use that with an array whose size is determined at runtime. Template parameters have to be known at compile time.
Topic archived. No new replies allowed.