I'm using the ben strasser C++ fast csv parser: https://github.com/ben-strasser/fast-cpp-csv-parser. It uses a variadic template to pass column values back to the while loop that processes the csv data:
io::CSVReader<2> in(csv_filename);
double x, y;
while(in.read_row(x,y)) {
//code with x and y
}
This calls the following function in the CSVReader class:
template<class ...ColType>
bool read_row(ColType& ...cols){
//snip
}
This works fine for me with my x and y values. However, I would like to expand this to use arbitrary dimensions. This means my data has a (known) number of columns I need to read. I would like to use something like this:
io::CSVReader<known_dimension> in(csvfname);
double data[known_dimension];
while(in.read_row(data)) {
//code with data[0],data[1],...,data[known_number]
}
However, this is not valid syntax. I need to "unpack" the array of doubles into separate arguments of pointers to my doubles. I'd like to do this without modifications to the fast csv parser.
See Question&Answers more detail:os