Const array of const, use its elements in array length definitions or set the value of template parameters
I need a constant array of constants in which its constants (elements of a constant array of constants) can be used where only a compile-time constant can be used, such as determining the length of an array.
eg:
int a[ my_const_array_of_const[0] ];
int b[ my_const_array_of_const[1] ];
template<int p>
foo() { ... };
foo< my_const_array_of_const[2] >();
I've tried solutions with other answers, but they weren't "permanent" enough to keep the compiler from throwing an error when used in the situations above.
How can I create a constant "my_const_array_of_const" to compile in such situations?
I need to set up a High-Level Synthesis (HLS) configuration. The C ++ HLS syntax is limited. Dynamic memory is not allowed, so I need to use static arrays. In addition, all compile-time constants can be used to optimize the hardware accelerator (this is the reason for using template parameters instead of variables).
source to share