How to print std::vector<std::string> into a row?
ManNam1 opened this issue · comments
ManNam1 commented
I need to convert vectors of string into table rows, but failing to do that. Could you please help?
ManNam1 commented
After some time I have come up with a solution (I suppose not the best):
Table table;
std::vector<variant<std::string, const char *, string_view, Table>> header;
header.push_back("corner cell");
for (auto element : some_vector_of_strings)
{
header.push_back(element );
}
table.add_row(Row_t{header});
Pranav commented
Hello.
For a vector of strings, e.g.,
std::vector<std::string> stringVec{"A", "B", "C"};
You should be able to do this in one line:
Row_t header(stringVec.begin(), stringVec.end());
ManNam1 commented
thank you very much, it works for me!