I think code below is self explanatory. I can easily pass static variable to template parameter and it work as expected. Using static array will cleanup code, so it look nicer, but unfortunately it doesn't compile due to error I pasted in comment. Note that it was compiled by gcc 10.2 with c++17 flag. So the question is how to pass array element to template.
#include <iostream>
#include <vector>
#include <tuple>
using DataTransfer = std::tuple<char, int>;
using DataPool = std::vector<DataTransfer>;
typedef struct Event
{
DataPool dataPool;
const char* description;
} Event;
template <Event& event>
class EventTransmitter
{
public:
EventTransmitter()
{
std::cout<<event.description<<"\n";
}
};
static Event ev1{ {{'d', 4}, {'a', 1}}, "Description 1"};
static Event ev2{ {{'g', 7}, {'b', 6}}, "Description 2"};
static Event evs[2] {
{ {{'d', 4}, {'a', 1}}, "Description 1"},
{ {{'g', 7}, {'b', 6}}, "Description 2"}
};
int main()
{
EventTransmitter<ev1> e1;
EventTransmitter<ev2> e2;
//EventTransmitter<evs[0]> e3;
//error: '& evs[0]' is not a valid template argument of
//type 'Event&' because 'evs[0]' is not a variable
return 0;
}