Unsigned narrowing to int

I got this template function for getting the size of an array [], and I want to use unsigned since, obviously, the array size will never be negative and I want to be prepared for any extremely large arrays I'll implement in the future. However, my compiler is warning me that size is narrowing to an int, so I am afraid that that information is either lost of distorted.

Here is the code:
template<typename T, unsigned size>
inline unsigned GAL(T(&)[size]){return size;}

Any way I can avoid this narrowing? I'm not used to working with templates...
#include <cstddef>

template < typename T, std::size_t N >
inline constexpr std::size_t size( T(&)[N] ){ return N; }
Thanks! But just to be sure... the size in "const expr std::size_t size" represents the name of the function, right?
Yes, size() is the function.

And constexpr is a (single) keyword
Topic archived. No new replies allowed.