Pass an array as template type
c++, templates
Solution
Try this:
Fifo<int[32], Q_SIZE> f;
Like this:
#include <iostream>
template <class T, int N>
struct Fifo {
T t;
};
int main () {
const int Q_SIZE = 32;
Fifo<int[32],Q_SIZE> f;
std::cout << sizeof f << "\n";
}
Problem
I need to pass an array as a template type. How can achieve it. For example, I want something like this. ``` Fifo<array, Q_SIZE> f; // This is a queue of arrays (to avoid false sharing) ``` What should I put in place of array? Assume I need an array of int. Also note that I don't want `std::vector` or a pointer to an array. I want the whole basic array, something equivalent of say int array[32].