docopt.cpp icon indicating copy to clipboard operation
docopt.cpp copied to clipboard

Use template classe for extraction of values ?

Open Luthaf opened this issue 10 years ago • 2 comments

The interface would be nicer if we could do

auto out = args["--output"].as<std::string>();
auto num = args["--num"].as<size_t>();

instead of

auto out = args["--output"].asString();
auto num = args["--num"].asLong();

I do not know if this is possible of not.

Luthaf avatar Jun 18 '15 23:06 Luthaf

It would be possible. However given that there are only 4 options, I'm not sure there would be a strong benefit to it.

jaredgrubb avatar Sep 28 '15 02:09 jaredgrubb

Mainly to silent compiler warning while doing

int num = args["--num"].asLong();

But I do agree this is not a big feature.

Luthaf avatar Sep 28 '15 19:09 Luthaf