cxxopts icon indicating copy to clipboard operation
cxxopts copied to clipboard

Multiple vectors

Open aosterthun opened this issue 4 years ago • 1 comments

Hi,

I would like to add an option to my application that allows repeated input of vectors.

I tried this:

("test", "vector input", cxxopts::value<std::vector<std::vector<float>>>()) 
const std::vector<std::vector<float>> tests = result["test"].as<std::vector<std::vector<float>>>();

when I call the application as follows:

./app --test=10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0 --test=10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0 --test=10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0,10.0

tests contains 30 entries with each entry being a vector of size one. I would expect 3 entries with each being a vector of size 10.

Is there a way to do that right now or is this not supported.

aosterthun avatar Oct 05 '20 10:10 aosterthun

That would need a bit of fiddling to do. Vector arguments are basically flattened out into a single vector, so I hadn't really thought of having a vector of vectors.

jarro2783 avatar Oct 05 '20 22:10 jarro2783