A
Andy Gibbs
Hi,
I am using gcc 4.5.3, which provides the error "multidimensional array must
have bounds for all dimensions except the first" if I try to define an array
type like...
typedef int array_t[][];
void test(array_t& arg);
I'm ok with this since I know C/C++ doesn't support this sort of array type.
However, it is possible to do this...
template <typename X>
struct add { typedef X type[]; };
typedef typename add<typename add<int>::type>::type array_t;
void test(array_t& arg);
.... and this *does* create a multidimensional array with unknown bounds. It
still errors on the function prototype: "error: parameter 'arg' includes
reference to array of unknown bound 'int [][]'" so while interesting it is
not much obvious use.
My question is this: have I simply managed to temporarily confuse the
compiler, or is there some (maybe obscure) part of the language that allows
multidimensional arrays with unknown bounds in some way?
Thanks for any light that may be shed on this matter!
Andy
I am using gcc 4.5.3, which provides the error "multidimensional array must
have bounds for all dimensions except the first" if I try to define an array
type like...
typedef int array_t[][];
void test(array_t& arg);
I'm ok with this since I know C/C++ doesn't support this sort of array type.
However, it is possible to do this...
template <typename X>
struct add { typedef X type[]; };
typedef typename add<typename add<int>::type>::type array_t;
void test(array_t& arg);
.... and this *does* create a multidimensional array with unknown bounds. It
still errors on the function prototype: "error: parameter 'arg' includes
reference to array of unknown bound 'int [][]'" so while interesting it is
not much obvious use.
My question is this: have I simply managed to temporarily confuse the
compiler, or is there some (maybe obscure) part of the language that allows
multidimensional arrays with unknown bounds in some way?
Thanks for any light that may be shed on this matter!
Andy