In llvm-3.4\include\llvm\ADT\STLExtras.h
, i see this function:
/// Find the length of an array.
template<class T, std::size_t N>
inline size_t array_lengthof(T (&)[N]) {
return N;
}
This function returns the array length:
int main(){
const char spaces[] = "dededesdf sdf sdfs fdsf"
"dadsds jsdfdfs ffjsdklfj dsfds";
std::cout << array_lengthof(spaces); //prints 54
return 0;
}
Can someone explain how the function works and also what the parameter T (&)[N]
means?
Are there any scenarios in which this function will not work?