C-style masks are very simple constructs that cannot be assigned, copied, or referenced in the same way as built-in or custom types do. To get the equivalent of passing an array by reference, you need the following syntax:
// non-const version template <typename T, size_t N> void fun( T (&x)[N] ) { ... } // const version template <typename T, size_t N> void fun( const T (&x)[N] ) { ... }
Please note: here the size of the array is also a parameter of the template that allows functions to work, all sizes of the array, since T[M] and T[N] are not the same for different M , N Also note that the function returns void. There is no way to return an array by value, since the array cannot be copied, as already mentioned.
juanchopanza
source share