jarro2783/cxxopts

Use of string_view's - documentation

Opened this issue · 5 comments

Can one reliably use values which are string_view's? Where the default value is a non-owning reference, and so is the parsed value?

The Wiki should clarify this point IMHO.

Can you give me an example of what you would like to do?

options.add_options()("filename", "description", cxxopts::value<std::string_view>())

and later

my_sv parse_result["filename"].as<std::string_view>();

and for that to work.

At the moment that won't work because the strings passed around are a temporary constructed as the command line is looked at.
I'm not sure how much work it would be to make it possible, because there are also the default and implicit values to deal with in the same code.

@jarro2783 : Ok, this is not an issue about making it work - just about mentioning whether it works on the Wiki page about options.

Ok sure. I'll add it to the wiki.